Thread: Complete Port I/O and Heap Problems :: Winsock

  1. #1
    Registered User
    Join Date
    Nov 2001

    Complete Port I/O and Heap Problems :: Winsock


    I am very close to finishing an IOCP Winsock program. However, there is one major bug that I have not been able to debug and determine a working solution. One reason is the fact that I do not know what causes this bug. Note that this now the only bug or at least the only one that Visual C++ Debugger finds.

    Here is the message from the debugger.

    HEAP[Program.exe]: HEAP: Free Heap block 36a9c8 modified at 36a9f4 after it was freed
    Unhandled exception at 0x77f7f570 in Program.exe: User breakpoint.
    I notice that the program crashes and Visual C++ Debugger outputs this message only when the IOCP handles multiple sockets. I do not have an accurate count, but I believe ten or more sockets will cause the program to crash. To my understand, IOCP can handle thousands of sockets. In fact, a working WSAAsyncSelect I/O model of this same program works great under hundreds of sockets at any given time.

    In terms of IOCP, what could be some causes of this heap problem?


  2. #2
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    It may not be a problem with the I/O completion port implementation at all. The behavior you describe (a crash after a certain condition is met) sounds like an error you'd get after memory in one part of the program has been corrupted, while the effects of the corruption are suddenly uncovered in another section.

    The debugger indicates that an object is apparently referenced or otherwise manipulated after its memory was freed, possibly causing heap damage that manifests itself in your IOCP system. The similarity of the addresses specified in the error message suggests that the allocation of the memory block and the illegal referencing are relatively close together, so you might want to check the areas around all allocations added just before the code broke.
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

  3. #3
    Registered User
    Join Date
    Nov 2001
    Excellent point. Thanks.

    I will check all allocations using new and make sure they remain valid.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. heap
    By George2 in forum Windows Programming
    Replies: 2
    Last Post: 11-10-2007, 10:49 PM
  2. heap question
    By mackol in forum C Programming
    Replies: 1
    Last Post: 11-30-2002, 04:03 AM
Website Security Test