Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Application terminates->*** buffer overflow detected ***
QtWS25 Last Chance

[SOLVED]Application terminates->*** buffer overflow detected ***

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 5.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aashish.lg
    wrote on last edited by
    #1

    I have developed one application which establishes QTCPSocket connection with windows server. Initially server sends around 30,000 bytes of data. which my application is not able to read in one go.
    Data is coming in chunks like first 2048 byets followed by 15000 bytes and then complete dtaa.
    In case if data is not completely received then I am not reading it from socket buffer, thereby using the socket buffer itself to store the data till I get complete.

    But in this case when I get data in chunks , my app is terminating , and I am getting error on console saying that
    *** buffer overflow detected ***.

    OS :- Open Suse 11.2 SP2
    Qt : - 4.6.2

    Please help what shall I do to avoid this.
    Note :- I tried below mention options also but no help
    m_commandSocket->setReadBufferSize(50000);
    m_commandSocket->setSocketOption(QAbstractSocket::LowDelayOption,1);

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Santosh Reddy
      wrote on last edited by
      #2

      This is a classic problem when using sockets, and nothing specific to Qt or C++ as such.

      The only solution is that you have to read the multiple chuncks and append them in your application. Basically you have to end up writing a simple application layer protocol.

      SS

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MuldeR
        wrote on last edited by
        #3

        The TCP protocol provides a "byte stream" abstraction. Even though that "stream" has to be transferred in limited-size IP packets on the lower layers, (and will be reassembled on the receiver's side), at the TCP-level you just have a continuous byte stream. Thus, you cannot expect that the "chunks" of bytes that pop out of the TCP connection are the same size and/or number as the chunks of bytes that the sender has pushed into the TCP connection. All you know is that all bytes will be delivered - eventually. In the correct order, but in chunks of arbitrary size. Consequently you won't get around appending all the "chunks" of data that you get from the TCP connection inside your own separate buffer. Also, you will have to decide yourself when a specific "message" (block of data) ends. That's why protocols based on TCP, such as HTTP, usually send a small header first. That header, besides other info, also contains the number of bytes that will follow until the "message" is complete.

        My OpenSource software at: http://muldersoft.com/

        Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

        Go visit the coop: http://youtu.be/Jay...

        1 Reply Last reply
        0
        • A Offline
          A Offline
          aashish.lg
          wrote on last edited by
          #4

          Thanks a lot guyz for your response.I put a proper buffering mechanism at my client place and I got rid of this problem.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved