Fwd: [test] crash with the following test

Hello, Since I couldn't solve the problem in boost-users list I'm forwarding here. ---------- Forwarded message ---------- From: Felipe Magno de Almeida <felipe.m.almeida@gmail.com> Date: Wed, Sep 22, 2010 at 2:07 PM Subject: [test] crash with the following test To: boost-users@lists.boost.org With boost 1.44.0 (the same happens with 1.43) the following test causes a crash in framework.ipp:388 with a dereference of a NULL pointer. The test_unit* res returns NULL from s_frk_impl().m_test_units[id] where id is 1. id is equal to 1 because when unit_test::framework::run is ran, id is INV_TEST_UNIT_ID is passed to it. Then in framework.ipp:399 if id == INV_TEST_UNIT_ID id is assigned the value in master_test_suite().p_id which is 1. I've verified that when master_test_suite is constructed it assigns INV_TEST_UNIT_ID to p_id, so I'm lost why this is 1 here. Then, back in framework.ipp:386 s_frk_impl().m_test_units there's only one element in the map and the id is 65535 and not one. -- test.cpp -- #define BOOST_TEST_MODULE parse_empty_import_documents #include <boost/test/included/unit_test.hpp> BOOST_AUTO_TEST_CASE (parse_empty_import_documents) { } -- test.cpp -- Any help would be appreciated. -- Felipe Magno de Almeida

On Fri, Sep 24, 2010 at 8:38 AM, Felipe Magno de Almeida <felipe.m.almeida@gmail.com> wrote:
Hello,
Since I couldn't solve the problem in boost-users list I'm forwarding here.
---------- Forwarded message ---------- From: Felipe Magno de Almeida <felipe.m.almeida@gmail.com> Date: Wed, Sep 22, 2010 at 2:07 PM Subject: [test] crash with the following test To: boost-users@lists.boost.org
With boost 1.44.0 (the same happens with 1.43) the following test causes a crash in framework.ipp:388 with a dereference of a NULL pointer. The test_unit* res returns NULL from s_frk_impl().m_test_units[id] where id is 1.
id is equal to 1 because when unit_test::framework::run is ran, id is INV_TEST_UNIT_ID is passed to it. Then in framework.ipp:399 if id == INV_TEST_UNIT_ID id is assigned the value in master_test_suite().p_id which is 1.
I've verified that when master_test_suite is constructed it assigns INV_TEST_UNIT_ID to p_id, so I'm lost why this is 1 here.
Then, back in framework.ipp:386 s_frk_impl().m_test_units there's only one element in the map and the id is 65535 and not one.
-- test.cpp -- #define BOOST_TEST_MODULE parse_empty_import_documents #include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_CASE (parse_empty_import_documents) { } -- test.cpp --
ping?
Any help would be appreciated. -- Felipe Magno de Almeida
-- Felipe Magno de Almeida

Hi Felipe, On Monday, 27. September 2010 16:44:31 Felipe Magno de Almeida wrote:
On Fri, Sep 24, 2010 at 8:38 AM, Felipe Magno de Almeida ping?
I think I know why you don´t get an answer...
<felipe.m.almeida@gmail.com> wrote:
With boost 1.44.0 (the same happens with 1.43) the following test causes a crash in framework.ipp:388 with a dereference of a NULL pointer. The test_unit* res returns NULL from s_frk_impl().m_test_units[id] where id is 1.
Please provide more information. A backtrace is better, a compileable test best. Some archive I can unpack and run "bjam" on, the very best ;-))
-- test.cpp -- #define BOOST_TEST_MODULE parse_empty_import_documents #include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_CASE (parse_empty_import_documents) { } -- test.cpp --
I see that you use the "included" variant. Without os, compiler (version) and flags, no way to debug this remote ;-)) Yours, Jürgen -- * Dipl.-Math. Jürgen Hunold ! Ingenieurgesellschaft für * voice: ++49 511 262926 57 ! Verkehrs- und Eisenbahnwesen mbH * fax : ++49 511 262926 99 ! Lister Straße 15 * juergen.hunold@ivembh.de ! www.ivembh.de * * Geschäftsführer: ! Sitz des Unternehmens: Hannover * Prof. Dr.-Ing. Thomas Siefer ! Amtsgericht Hannover, HRB 56965 * PD Dr.-Ing. Alfons Radtke !

On Tue, Sep 28, 2010 at 6:06 AM, Jürgen Hunold <juergen.hunold@ivembh.de> wrote: > Hi Felipe, > > On Monday, 27. September 2010 16:44:31 Felipe Magno de Almeida wrote: >> On Fri, Sep 24, 2010 at 8:38 AM, Felipe Magno de Almeida >> ping? Hi Jurgen, > I think I know why you don´t get an answer... Thanks, Here it is: A stacktrace: > test1.exe!boost::unit_test::framework::get(unsigned long id=1, boost::unit_test::test_unit_type t=tut_suite) Line 388 + 0x8 bytes C++ test1.exe!boost::unit_test::framework::get<boost::unit_test::test_suite>(unsigned long id=1) Line 73 + 0xb bytes C++ test1.exe!boost::unit_test::traverse_test_tree(unsigned long id=1, boost::unit_test::test_tree_visitor & V={...}) Line 234 + 0xd bytes C++ test1.exe!boost::unit_test::framework::run(unsigned long id=1, bool continue_test=true) Line 403 + 0xd bytes C++ test1.exe!boost::unit_test::unit_test_main(bool (void)* init_func=0x004103c0, int argc=1, char * * argv=0x00354358) Line 185 + 0x9 bytes C++ test1.exe!main(int argc=1, char * * argv=0x00354358) Line 63 + 0x12 bytes C++ test1.exe!__tmainCRTStartup() Line 582 + 0x19 bytes C test1.exe!mainCRTStartup() Line 399 C kernel32.dll!_BaseProcessStart@4() + 0x23 bytes > Please provide more information. A backtrace is better, a compileable test > best. Some archive I can unpack and run "bjam" on, the very best ;-)) Attached a Jamroot and test.cpp that shows the problem. I'm using Windows XP Pro SP3 and msvc-9.0. But it is reproduceable with msvc-10.0express and msvc-8.0. Thanks in advance, -- Felipe Magno de Almeida

Hi Felipe, On Tuesday, 28. September 2010 20:00:15 Felipe Magno de Almeida wrote:
Please provide more information. A backtrace is better, a compileable test best. Some archive I can unpack and run "bjam" on, the very best ;-))
Attached a Jamroot and test.cpp that shows the problem.
Thanks.
I'm using Windows XP Pro SP3 and msvc-9.0. But it is reproduceable with msvc-10.0express and msvc-8.0.
Not surprisingly, this works with gcc-4.4 on linux. msvc-9.0 complains with BOOST_ROOT\boost/test/impl/unit_test_main.ipp(175) : error C2491: 'boost::unit_test::unit_test_main' : definition of dllimport function not allowed BOOST_ROOT\boost/test/impl/unit_test_monitor.ipp(61) : warning C4273: 'boost::unit_test::unit_test_monitor_t::execute_and_translate' : inconsistent dll linkage and so fails to build the example for me. The main mistake is that you link against the Unit-Test library and use the "included" variant at the same time. Either removing the dependency on the library and adding the include paths with <use>: project test : requirements <use>/boost//headers ; alias test : [ run test1.cpp ] ; or changing test1.cpp to #include the library header only: //#include <boost/test/included/unit_test.hpp> #include <boost/test/unit_test.hpp> will fix this. Otherwise, you get _serious_ UB. Yours, Jürgen -- * Dipl.-Math. Jürgen Hunold ! Ingenieurgesellschaft für * voice: ++49 511 262926 57 ! Verkehrs- und Eisenbahnwesen mbH * fax : ++49 511 262926 99 ! Lister Straße 15 * juergen.hunold@ivembh.de ! www.ivembh.de * * Geschäftsführer: ! Sitz des Unternehmens: Hannover * Prof. Dr.-Ing. Thomas Siefer ! Amtsgericht Hannover, HRB 56965 * PD Dr.-Ing. Alfons Radtke !

On Tue, Sep 28, 2010 at 3:33 PM, Jürgen Hunold <juergen.hunold@ivembh.de> wrote:
Hi Felipe,
On Tuesday, 28. September 2010 20:00:15 Felipe Magno de Almeida wrote:
Please provide more information. A backtrace is better, a compileable test best. Some archive I can unpack and run "bjam" on, the very best ;-))
Attached a Jamroot and test.cpp that shows the problem.
Thanks.
or changing test1.cpp to #include the library header only:
//#include <boost/test/included/unit_test.hpp> #include <boost/test/unit_test.hpp>
will fix this. Otherwise, you get _serious_ UB.
Thanks. I wasn't aware that the included directory was meant as a header-only version of the library. I wrongly assumed it was like fusion uses the include directory, as some way to flatten the include hierarchy.
Yours,
Jürgen -- * Dipl.-Math. Jürgen Hunold ! Ingenieurgesellschaft für * voice: ++49 511 262926 57 ! Verkehrs- und Eisenbahnwesen mbH * fax : ++49 511 262926 99 ! Lister Straße 15 * juergen.hunold@ivembh.de ! www.ivembh.de * * Geschäftsführer: ! Sitz des Unternehmens: Hannover * Prof. Dr.-Ing. Thomas Siefer ! Amtsgericht Hannover, HRB 56965 * PD Dr.-Ing. Alfons Radtke !
Thank you very much, -- Felipe Magno de Almeida
participants (2)
-
Felipe Magno de Almeida
-
Jürgen Hunold