Heap corruption caused by a lib function

hi all

i am using a .lib in my application and there is function that i call which reads a file and fills some structure variables. variables can go in thousands. when i run it is throws an exception saying

"Windows has triggered a breakpoint in ConsolTest.exe.

This may be due to a corruption of the heap, and indicates a bug in ConsolTest.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information"

what could be going wrong

Aamer



Answer this question

Heap corruption caused by a lib function

  • asalcedo

    Can't you just compile the lib using VS2005 instead of VC++6 Mixing compilers can be quite troublesome.
  • Vitalijus

    Ah, I understand. Then maybe the compiler options are different. Check the following option in Project Properties:

    Configuration Properties\C/C++\Code Generation

    Runtime Library

    The runtime library should be the same for both the static lib and the project that uses the static lib. You can use any option you like here just made sure you have the same option in both projects.


  • Xelestial

    Actually I already have compiled that with the VC++.NET 2005. But the problem remains there. I dont know what is heap corruption.


  • Beetle54

    I actually made the lib with VC++6 and then built the project with the VC++.NET 2005. The lib is starting the function well. Here i put the call stack trace. at the bottom is our function which causes the problem. I dont know what is going on after that.

    NTDLL.DLL!77f9193c()
    [Frames below may be incorrect and/or missing, no symbols loaded for NTDLL.DLL]
    NTDLL.DLL!77fb2a30()
    NTDLL.DLL!77f9bf12()
    NTDLL.DLL!77f9bf68()
    NTDLL.DLL!77f9bf98()
    NTDLL.DLL!77f9c1ea()
    NTDLL.DLL!77f9bf98()
    NTDLL.DLL!77f9c1ea()
    NTDLL.DLL!77f9bf98()
    NTDLL.DLL!77f9c1ea()
    NTDLL.DLL!77f9bf68()
    NTDLL.DLL!77f9bf98()
    NTDLL.DLL!77fb064e()
    NTDLL.DLL!77fca907()
    NTDLL.DLL!77f9bd5a()
    NTDLL.DLL!77fb083a()
    NTDLL.DLL!77fb0812()

    msvcr80d.dll!write_string(char * string=0x0012e86c, int len=1239156, _iobuf * f=0x0012e8b4, int * pnumwritten=0x10228400) Line 2568 + 0x19 bytes C++

    msvcr80d.dll!_output_l(_iobuf * stream=0x0012eb1c, const char * format=0x0012f0b8, localeinfo_struct * plocinfo=0x00187060, char * argptr=0xcccccccc) Line 2258 + 0x18 bytes C++

    ConsolTest.exe!TCP_Segment_Integrity_Checker(Packet * pPkt=0x0012ee10, Connection * * HeadConnList=0x0040f7f8, TCPAbnormal_Occurances * pAbOccurance=0x0040f7fc) Line 275 + 0x12 bytes C

    Aamer


  • HappyZimmer

    One of the usual situations is that the lib was compiled with a different C runtime. Do you know with what version of Visual Studio it was compiled What compiler options were in use
  • Heap corruption caused by a lib function