[test] Crash when running my unit tests

Hi there, when I try to run my tests the unit testing framework seems to crash for no apparent reason. The point it's crashing is in unit_test_suite.ipp[263]. It seems to crash before entering the first test. The c++ runtime at this points tries to delete the memory of a string which triggers the assertion. _ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)); Here is my scenario: Everything used to run just fine before I added a new file containing more tests. Meaning all of my tests are scattered around a couple of files ( 20 files ) which sum up to about 120 tests. I don't think that this usage is anything but exceptional. When I exclude the new test file the tests are running fine. When including the new test file it crashes. I'm running the boost trunk on a windows xp using MSVC 2005. Anyone any idea what I can do about this? My code is available here: http://gil-contributions.googlecode.com/svn/trunk/ The tests are here: http://gil-contributions.googlecode.com/svn/trunk/gil_2/libs/gil/io_new/test... Any help is more than welcome. Thanks ahead, Christian

Thanks Ovanes for your quick reply. The only global variables I'm using in my test suite are in some strings representing paths and filenames. I have removed them to see if that changes anything but it doesn't. Same problem as before. The problem seems to be with tiff_test.cpp. When excluding it from the test suite all works. Including it generates the crash. One more thing regarding my test suite. I'm testing various image formats, like bmp, png, etc, and each format basically runs through similar tests. To avoid name collisions I use namespaces for each format. Each of those namespaces contain tests with the same name, like this: bmp_test.cpp: namespace bmp_test { BOOST_AUTO_TEST_CASE( read_image_test ) {} } png_test.cpp: namespace png_test { BOOST_AUTO_TEST_CASE( read_image_test ) {} } I hope such use case is fine with boost::test. Regards, Christian On Wed, Apr 29, 2009 at 7:30 PM, Ovanes Markarian <om_boost@keywallet.com> wrote:

On Thu, Apr 30, 2009 at 5:32 PM, Christian Henning <chhenning@gmail.com>wrote:
Christian, to avoid name collisions use anonymous namespaces if you don't really require the names outside the compilation unit: namespace { BOOST_AUTO_TEST_CASE(read_image_test){} } This will ensure internal linkage for the names. My other other suggestion would be trying to disable as many TC's as possible in the problematic CPP to see what's going wrong there. If you debug in MSVC, you can switch on VS to break into the code as soon as some violation happens. This way you will be able to break into global initialization as well. Regards, Ovanes

Hi Ovanes,
Thanks. I changed my code.
What do you mean by switch on VS? The debugger automatically breaks when the assertion fires. Though, I know exactly where it happens. I sent the location in my first email. I did some testing in that direction but the crash happens before any of the test case are invoked by boost::test. Looking at the call stack reveals that boost::test is preparing the first test name, which is done in "make_test_case(...)" inside the file unit_test_suite_impl.hpp[255]. I don't know how boost::test is generating the loop to invoke all test cases but maybe that process is the problem? Can you try to compile the test suite? There is jamfile if that helps. Thanks, Christian

Hi there,
I have gotten rid of all namespaces and are now enforcing unique names for all my test cases. Usually if there equal names around the linker complains. I compiled, but still the same error occurs. I have checked in the recent changes in case someone would like to try by himself. Regards, Christian

It seems to have been a problem with the Windows runtime libraries. I'm used to link to the release versions of the image libraries and that might have screwed things up. After compiling all those image libs into debug versions I can now run the debug version of my test suite. Cool. Too bad that all of this took too much time to figure out. I apologize if I have wasted someone's time. :-( Regards, Christian On Thu, Apr 30, 2009 at 3:11 PM, Christian Henning <chhenning@gmail.com> wrote:

Christian Henning <chhenning <at> gmail.com> writes:
No. I do not think so. You need to create actual test suites (they include the namespace as well) BOOST_AUTO_TEST_SUITE( bmp_test ) BOOST_AUTO_TEST_CASE( read_image_test ) {} BOOST_AUTO_TEST_SUITE_END() If you still see the issue please post simple example. You are using trunk version, right?

Gennadiy, thanks for your input. As I wrote in my last email the problem was fixed by linking to the correct runtime lib. One of my image libs was not correctly built. I cannot reproduce the problem anymore. Regards, Christian On Fri, May 8, 2009 at 4:30 AM, Gennadiy Rozental <rogeeff@gmail.com> wrote:
participants (4)
-
Christian Henning
-
Gennadiy Rozental
-
Ovanes Markarian
-
Steven Watanabe