Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost.serialization] shared object plugin
From: Robert Ramey (ramey_at_[hidden])
Date: 2012-08-08 12:55:37


Giampiero Gabbiani wrote:
> Hi Robert,
> I tried the test_dll_plugin (with CMAKE under Linux) that seems to
> cover my case.
>
> add_executable(test_dll_plugin test_dll_plugin.cpp
> polymorphic_base.cpp) target_link_libraries(test_dll_plugin dl
> boost_serialization boost_filesystem)
>
> add_library(plugin_polymorphic_derived2 SHARED
> polymorphic_derived2.cpp)
>
> it compiles (under Linux) but during execution I get:
>
> test_dll_plugin: /usr/include/boost/serialization/singleton.hpp:137:
> static T& boost::serialization::singleton<T>::get_mutable_instance()
> [with T =
> boost::archive::detail::extra_detail::guid_initializer<polymorphic_derived2>]:
> Assertion `! is_locked()' failed.
>

OK - I looked into this. The key facts are:

I included code assertions which check that all static structures are
initialized
before main() is called. I did this to make sure detect any thread safey
issues
that might crop up of archives are created on separate threads. This code
guarentees that the global static list of serializable types is not messed
with from different threads. I did it this way as I didn't want to guard
all the serialization calls to check this structure with locks - which would
be a performance killer.

BUT, this presumes that all DLLs which use the table are loaded
BEFORE main is called. This the most common case, but it conflicts
with our usage case. Your usage case is a very important one
however and it must be supported. And it should be used much
more often. I'm amazed, surprised, and disappointed that no one
has spotted this before.

Soooooo

a) just comment out the assertion in your header.
b) think about this some more.
c) create a track item for this issue describing the problem and
proposing a better solution. Something like calling some "other"
function to turn off the assertion.

Robert Ramey


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net