1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
2 | // test_multi_shared_lib.cpp: test that implementation of extented_type_info |
3 | // works when using multiple shared libraries |
4 | // |
5 | // This reproduces a crash that occurred when multiple shared libraries were |
6 | // using Boost.Serialization built statically. That causes core singletons to be |
7 | // instantiated in each shared library separately. Due to some destruction order |
8 | // mixup in the context of shared libraries on linux it is possible, that |
9 | // singletons accessed in destructors of other singletons are already destructed. |
10 | // Accessing them will then lead to a crash or memory corruption. |
11 | // For this we need 2 shared libraries, linked against static boost. They need to |
12 | // instantiate extended_type_info_typeid with different types, either by serializing |
13 | // 2 types (which will do that internally) or by accessing the singletons directly. |
14 | |
15 | // (C) Copyright 2018 Alexander Grund |
16 | // Use, modification and distribution is subject to the Boost Software |
17 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
18 | // http://www.boost.org/LICENSE_1_0.txt) |
19 | |
20 | #include <boost/serialization/config.hpp> |
21 | |
22 | // Both shall instantiate different(!) singletons and return true |
23 | BOOST_SYMBOL_IMPORT bool f(); |
24 | BOOST_SYMBOL_IMPORT bool g(); |
25 | |
26 | int main(int argc, char**){ |
27 | if(f() && g()) |
28 | return 0; |
29 | return 1; |
30 | } |
31 | |