id summary reporter owner description type status milestone component version severity resolution keywords cc 11204 undefined behavior sanitizer complains about runtime_error thrown in serialization/singleton.hpp before main() Georg Sauthoff Robert Ramey "How to reproduce: {{{ #include #include #include #include #include using namespace std; struct Data { vector v; }; namespace boost { namespace serialization { template void serialize(Archive & a, Data &d, const unsigned int version) { a & d.v; } } } int main(int argc, char **argv) { if (argc > 10) { ifstream f(""/dev/null""); boost::archive::text_iarchive a(f); Data d; a >> d; } else { ofstream f(""/dev/null""); boost::archive::text_oarchive a(f); Data d; a << d; } return 0; } }}} Compile via: {{{ $ g++ -g -std=c++11 -I/home/juser/src/boost/modular-boost \ -L/home/juser/src/boost/modular-boost/stage/lib \ -Wl,-R/home/juser/src/boost/modular-boost/stage/lib \ -fsanitize=undefined test_serialize.cc \ -o test_serialize -lboost_serialization }}} (GCC's undefined behavior sanitizer is enabled with {{{-fsanitize=undefined}}}) Run: {{{ $ ./test_serialize }}} Expected output: {{{ }}} (nothing) Actual output: {{{ /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:132:21: runtime error: reference binding to null pointer of type 'const struct extended_type_info_typeid' /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:132:21: runtime error: reference binding to null pointer of type 'const struct iserializer' /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:132:21: runtime error: reference binding to null pointer of type 'const struct oserializer' /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:132:21: runtime error: reference binding to null pointer of type 'const struct extended_type_info_typeid' /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:132:21: runtime error: reference binding to null pointer of type 'const struct oserializer' /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:132:21: runtime error: reference binding to null pointer of type 'const struct iserializer' }}} First backtrace when breaking in singleton.hpp:132: {{{ (gdb) bt #0 boost::serialization::singleton >::get_instance () at /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:132 #1 0x0000000000407ebd in boost::serialization::singleton >::get_const_instance () at /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:141 #2 0x0000000000407924 in boost::archive::detail::iserializer::iserializer ( this=0x640a60 >::get_instance()::t>) at /home/juser/src/boost/modular-boost/boost/archive/detail/iserializer.hpp:128 #3 0x0000000000407373 in boost::serialization::detail::singleton_wrapper >::singleton_wrapper ( this=0x640a60 >::get_instance()::t>) at /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:106 #4 0x000000000040740b in boost::serialization::singleton >::get_instance () at /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:128 #5 0x0000000000404a13 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at /home/juser/src/boost/modular-boost/boost/serialization/singleton.hpp:149 #6 0x0000000000404c6e in _GLOBAL__sub_I_main () at test_serialize.cc:43 #7 0x000000000041abbd in __libc_csu_init () #8 0x00007ffff62e5f6f in __libc_start_main (main=0x4047c6 , argc=1, argv=0x7fffffffdfb8, init=0x41ab70 <__libc_csu_init>, fini=, rtld_fini=, stack_end=0x7fffffffdfa8) at libc-start.c:245 #9 0x00000000004046f9 in _start () }}} " Bugs reopened To Be Determined serialization Boost Development Trunk Problem