[Serialization]: SIGSEGV on Mingw32, during global static data initialization (runs ok on Linux)
Hi,
I've been using boost Serialization library (release v1_33_1) on Linux
without problems, with g++ compiler of both v3.3.6 & v4.1.1. My program
serialzes boost::shared_ptr of polymorphic types, and BOOST_CLASS_EXPORT()
and BOOST_SERIALIZATION_SHARED_PTR() are used.
However, when the same program is ported & run on mingw32 (w/ g++ v3.4.5 on
WinXP), it generates SIGSEGV before my main() is called. and here's the
stack trace:
Program received signal SIGSEGV, Segmentation fault.
0x6e3759a3 in boost::archive::detail::basic_serializer::basic_serializer (
this=0x4, eti=@0x813484)
at /opt/boost/boost_1_33_1/boost/archive/detail/basic_serializer.hpp:37
37 {}
(gdb) bt
#0 0x6e3759a3 in boost::archive::detail::basic_serializer::basic_serializer
(
this=0x4, eti=@0x813484)
at /opt/boost/boost_1_33_1/boost/archive/detail/basic_serializer.hpp:37
#1 0x6e34220b in
boost::archive::detail::basic_oserializer::basic_oserializer
(this=0x0, eti=@0x813484)
at
/opt/boost/boost_1_33_1/libs/serialization/build/../src/basic_oserializer.cpp:24
#2 0x005fb394 in boost::archive::detail::pointer_oserializer
Just out of curiosity? are you doing multi-threading?
Robert Ramey
"Jeffrey Chang"
Robert:
Yes, this program uses boost multi-thread library of
"boost_thread-mgw-mt-d-1_33_1.dll". boost::asio library (header only) is
also used.
--- Jeffrey
On 9/26/06, Robert Ramey
Just out of curiosity? are you doing multi-threading?
Robert Ramey
"Jeffrey Chang"
wrote in message news:8782a5590609261453p6f8542cfp2cb64d86754527c7@mail.gmail.com... Hi, I've been using boost Serialization library (release v1_33_1) on Linux without problems, with g++ compiler of both v3.3.6 & v4.1.1. My program serialzes boost::shared_ptr of polymorphic types, and BOOST_CLASS_EXPORT() and BOOST_SERIALIZATION_SHARED_PTR() are used.
However, when the same program is ported & run on mingw32 (w/ g++ v3.4.5on WinXP), it generates SIGSEGV before my main() is called. and here's the stack trace:
Program received signal SIGSEGV, Segmentation fault. 0x6e3759a3 in boost::archive::detail::basic_serializer::basic_serializer ( this=0x4, eti=@0x813484) at /opt/boost/boost_1_33_1/boost/archive/detail/basic_serializer.hpp:37 37 {} (gdb) bt #0 0x6e3759a3 in boost::archive::detail::basic_serializer::basic_serializer ( this=0x4, eti=@0x813484) at /opt/boost/boost_1_33_1/boost/archive/detail/basic_serializer.hpp:37 #1 0x6e34220b in boost::archive::detail::basic_oserializer::basic_oserializer (this=0x0, eti=@0x813484) at /opt/boost/boost_1_33_1/libs/serialization/build/../src/basic_oserializer.cpp:24 #2 0x005fb394 in boost::archive::detail::pointer_oserializer
::pointer_oserializer (this=0x813164) at /opt/boost/boost_1_33_1/boost/serialization/extended_type_info_typeid.hpp:95 #3 0x00477c12 in __static_initialization_and_destruction_1 ( __initialize_p=8467588, __priority=65535) at /opt/boost/boost_1_33_1/boost/archive/detail/oserializer.hpp:198 #4 0x004c5a57 in __main () at /opt/boost/boost_1_33_1/boost/archive/detail/oserializer.hpp:198 #5 0x00404568 in main (argc=1, argv=0x3d45f8) at ../../src/HmcMain.cpp:231 (gdb) I cannot connect the logic between stack frame #3 and #2; it seems trying to instantiate some global static data when SIGSEGV happens. Is there some dependency on order of global static data initialization to be satisfied for using BOOST_CLASS_EXPORT/BOOST_SERIALIZATION_SHARED_PTR? HmcBase is the base class for my polymorphic types, and all my code are statically linked, while "boost_serialization-mgw-d-1_33_1.dll" is used here. I saw some discussion in this mailing list on "Serializing classes defined in DLLs"http://news.gmane.org/find-root.php?message_id=%3c432FF0C3.5010002%40intopii...a year ago, but don't know what's the current status on it and whether this case is related to it.
Thanks for any hit,
--- Jeffrey
------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
It has been recently discovered that, contrary to intention and belief, archives are not currently thread-safe.
The issue is currently being investigated but a fix won't appear before version 1.35 - at the earliest.
In the mean time, perhaps you can avoid the issue by sycronizing access to archives.
Robert Ramey
"Jeffrey Chang"
Robert:
Thanks for the info. From the gdb output, my program was still
single-threaded when it seg-faults:
(gdb) info thread
* 1 thread 3800.0x3f8 0x6e3759a3 in
boost::archive::detail::basic_serializer::basic_serializer (this=0x4,
eti=@0x816484)
at
c:/e2e/prj/awit.hipeer.trunk/contrib/oss.boost.release/boost_1_33_1/boost/archive/detail/basic_serializer.hpp:37
I do find a workaround for my problem: use a single complication unit (*.o)
for all my *.cpp files that does #include serialization headers, which are
It has been recently discovered that, contrary to intention and belief, archives are not currently thread-safe.
The issue is currently being investigated but a fix won't appear before version 1.35 - at the earliest.
In the mean time, perhaps you can avoid the issue by sycronizing access to archives.
Robert Ramey
"Jeffrey Chang"
wrote in message news:8782a5590609261636j3ee55435pe578c78290ec7d1c@mail.gmail.com... Robert: Yes, this program uses boost multi-thread library of "boost_thread-mgw-mt-d-1_33_1.dll". boost::asio library (header only) is also used.
--- Jeffrey
On 9/26/06, Robert Ramey
wrote: Just out of curiosity? are you doing multi-threading?
Robert Ramey
"Jeffrey Chang"
wrote in message news:8782a5590609261453p6f8542cfp2cb64d86754527c7@mail.gmail.com ... Hi, I've been using boost Serialization library (release v1_33_1) on Linux without problems, with g++ compiler of both v3.3.6 & v4.1.1. My program serialzes boost::shared_ptr of polymorphic types, and BOOST_CLASS_EXPORT() and BOOST_SERIALIZATION_SHARED_PTR() are used.
However, when the same program is ported & run on mingw32 (w/ g++ v3.4.5on WinXP), it generates SIGSEGV before my main() is called. and here's the stack trace:
Program received signal SIGSEGV, Segmentation fault. 0x6e3759a3 in boost::archive::detail::basic_serializer::basic_serializer ( this=0x4, eti=@0x813484) at /opt/boost/boost_1_33_1/boost/archive/detail/basic_serializer.hpp:37 37 {} (gdb) bt #0 0x6e3759a3 in boost::archive::detail::basic_serializer::basic_serializer ( this=0x4, eti=@0x813484) at /opt/boost/boost_1_33_1/boost/archive/detail/basic_serializer.hpp:37 #1 0x6e34220b in boost::archive::detail::basic_oserializer::basic_oserializer (this=0x0, eti=@0x813484) at /opt/boost/boost_1_33_1/libs/serialization/build/../src/basic_oserializer.cpp:24 #2 0x005fb394 in boost::archive::detail::pointer_oserializer
::pointer_oserializer (this=0x813164) at /opt/boost/boost_1_33_1/boost/serialization/extended_type_info_typeid.hpp:95 #3 0x00477c12 in __static_initialization_and_destruction_1 ( __initialize_p=8467588, __priority=65535) at /opt/boost/boost_1_33_1/boost/archive/detail/oserializer.hpp:198 #4 0x004c5a57 in __main () at /opt/boost/boost_1_33_1/boost/archive/detail/oserializer.hpp:198 #5 0x00404568 in main (argc=1, argv=0x3d45f8) at ../../src/HmcMain.cpp:231 (gdb) I cannot connect the logic between stack frame #3 and #2; it seems trying to instantiate some global static data when SIGSEGV happens. Is there some dependency on order of global static data initialization to be satisfied for using BOOST_CLASS_EXPORT/BOOST_SERIALIZATION_SHARED_PTR? HmcBase is the base class for my polymorphic types, and all my code are statically linked, while "boost_serialization-mgw-d-1_33_1.dll" is used here. I saw some discussion in this mailing list on "Serializing classes defined in DLLs" http://news.gmane.org/find-root.php?message_id=%3c432FF0C3.5010002%40intopii...a year ago, but don't know what's the current status on it and whether this case is related to it.
Thanks for any hit,
--- Jeffrey
------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Since the program halts at the get_instance() call at line boost_1_33_1/boost/serialization/extended_type_info_typeid.hpp:95, I'm wondering the discussion a few months ago: Re: Boost serialization : concurrency (was Possibletoappend...) has anything to do with the safety of local static access across multiple C++ compilation unit, in addition to issues with thread-safety. Anyway, is there any documentation on how to use boost::serialization library correctly across multiple DLLs & explain what it is doing during initialization/destruction time? **** Are you using DLLS as well? Robert Ramey
On 9/27/06, Robert Ramey
Since the program halts at the get_instance() call at line boost_1_33_1/boost/serialization/extended_type_info_typeid.hpp:95, I'm wondering the discussion a few months ago: Re: Boost serialization : concurrency (was Possibletoappend...)http://news.gmane.org/find-root.php?message_id=%3ceektei%248hm%241%40sea.gma... has anything to do with the safety of local static access across multiple C++ compilation unit, in addition to issues with thread-safety. Anyway, is there any documentation on how to use boost::serialization library correctly across multiple DLLs & explain what it is doing during initialization/destruction time?
**** Are you using DLLS as well?
Not yet, but plan to use DLL soon. Though my workaround works so far, I'm still not 100% sure what the root cause is for the SIGSEGV fault (Any explanation?). This makes me nervous in DLL'ize my code w.r.t. serialization. It'd be great there's clear guidelines on what to do/not to do with DLL (or global static, in general) for user of boost::serialization. --- Jeffrey Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I will add some more information to the documenation concerning DLLS and threading. This will be a summary of the anecdotal information that has trickled in on an occasional basis. In addition. a) I've made changes which I hope will force initialization and construction of all global registry tables to occur at pre-main time. I'm hoping that this will make archives thread-safe as they are meant to be. b) I've made incremental changes to support serialization code in DLLS. It turns out to be difficult and a lot of work to set a good test for this. The problem is that when a DLL is dynamically loaded, the global/static variables defined in that DLL are constructed/initialized. When they DLL is unloaded, these have to be destroyed and removed from the tables. Its not clear to me when DLLS are loaded - probably when needed - which suggests that its possible that the global/static tables could be altered after pre-main time - which in turn could create problems is there are parallel threads using archives. Just a little taste of what's involved. Robert Ramey Anyway, is there any documentation on how to use boost::serialization library correctly across multiple DLLs & explain what it is doing during initialization/destruction time? **** Are you using DLLS as well? Not yet, but plan to use DLL soon. Though my workaround works so far, I'm still not 100% sure what the root cause is for the SIGSEGV fault (Any explanation?). *** can you trap this in the debugger and send the stack trace? This makes me nervous in DLL'ize my code w.r.t. serialization. It'd be great there's clear guidelines on what to do/not to do with DLL (or global static, in general) for user of boost::serialization.
participants (2)
-
Jeffrey Chang
-
Robert Ramey