[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
Christian,
unfortunately I did not look into your files, but as an idea is there any
chance that static or global variables initialiazation order is involved?
Ovanes
On Wed, Apr 29, 2009 at 11:26 PM, Christian Henning
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
Christian,
unfortunately I did not look into your files, but as an idea is there any chance that static or global variables initialiazation order is involved?
Ovanes
On Wed, Apr 29, 2009 at 11:26 PM, Christian Henning
wrote: 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
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Thu, Apr 30, 2009 at 5:32 PM, Christian Henning
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
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,
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.
Thanks. I changed my code.
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.
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
AMDG Christian Henning wrote:
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.
It probably isn't. Boost.Test uses the name as an identifier to select the tests to run and it doesn't know about namespaces. It ought to work if you put the tests in different test suites. In Christ, Steven Watanabe
Hi there,
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.
It probably isn't. Boost.Test uses the name as an identifier to select the tests to run and it doesn't know about namespaces. It ought to work if you put the tests in different test suites.
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
Hi there,
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.
It probably isn't. Boost.Test uses the name as an identifier to select the tests to run and it doesn't know about namespaces. It ought to work if you put the tests in different test suites.
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
Christian Henning
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.
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
Christian Henning
writes: 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.
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?
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Christian Henning
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 still recommend using test suites instead of plain C++ namespaces. On top of everything else it allows you to run only test cases pertinent to particular image type. Gennadiy
Christian Henning
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].
_ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse));
Can you post whole stack trace?
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.
What if you exclude some other files? Can you create simple test module that reproduce the issue? Gennadiy
participants (4)
-
Christian Henning
-
Gennadiy Rozental
-
Ovanes Markarian
-
Steven Watanabe