|
Boost : |
From: Doug Gregor (dgregor_at_[hidden])
Date: 2007-09-13 10:02:05
On Sep 13, 2007, at 12:24 AM, Sean Huang wrote:
> The following code in function_template.hpp has me concerned:
>
> template<typename Functor>
> void assign_to(Functor f)
> {
> static vtable_type stored_vtable(f);
> if (stored_vtable.assign_to(f, functor)) vtable =
> &stored_vtable;
> else vtable = 0;
> }
>
> The function scope statics are not thread-safe as far as I know and
> this is
> potentially a show stopper for us (we're in the process of
> upgrading from
> 1.33.1 to 1.34+. Same usage in boost.serialization caused our
> application
> (very heavy threaded) to crash.
The good news is that even though this requires dynamic
initialization of the static, the initialization itself is merely
copying two function pointers. Running the initialization twice is no
problem: it will just provide the same pointer values. The bad news
is that, if the initialization gets skipped, you will get a crash.
> Is there any plan to fix this? Or I'm wrong and this is not a problem.
Well, *now* there's a plan to fix it :)
Thanks for reporting this. It's ticket #1260, and the fix will be to
turn that dynamic initialization of stored_vtable into static
initialization, so that no code will actually need to be executed.
- Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk