Problems in Release Build but not Debug

  • gerard morris

    gerard morris - 2011-12-06


    I am using Visual Studio 2008 and I am encountering a problem with cppunit. The program compiles and runs perfectly fine in debug but in release I am getting the following

    "HEAP: Invalid address specified to RtlFreeHeap( 00A80000, 00182448 )
    Windows has triggered a breakpoint in CppUnitTestRunner.exe."

    Now when tracking through the code it is happening after the following line is called:
    runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 

    This goes into the CPPUNIT_TEST( testAssertThrow ); area, and the error is shown.

    Has anyone encountered an error like this before? If so, how do I fix this ? I am on a 64 bit system if that makes any difference.

    Thanks for your time,

  • demo

    demo - 2012-02-07

    Gerard you aren't alone :), I think I am hitting the exact same issue.
    After runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());  seems heap will be corrupted if you have more than one test method in the registered test suite.
    And I tried on a clean x86 machine with empty VS 2005 project (not 2008), this still repros. Let me know if you need more info, I can provide the project or dump if necessary.

    Thanks for any pointers, will be very appreciated…

  • demo

    demo - 2012-02-08

    I poked around and found some leads, but still out of idea how can I get it work.
    We are linking the Runtime Libraries as /MT in Release Builds, for all production code and test code, and seems this breaks cppunit.
    To prove this, under Debug build, switch Runtime Libraries from /MDd to /MTd, the exact same issue will happen.
    This is kind of blocker for all products if they are releasing as /MT?

    Please help out…

  • demo

    demo - 2012-02-08

    I think I found the trick. Compliling as MT will cause multiple copy of CRT being hosted in process, so memory allocated in exe will not be able to freed in dll as educated here:
    So because of the nature of cppunit, we  cannot build it as dll using MT.
    Get this away by static linking cppunit using /MT.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks