Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#1260 closed Bugs (fixed)

Thread-safety problem in Boost.Function

Reported by: Douglas Gregor Owned by: Douglas Gregor
Milestone: To Be Determined Component: function
Version: Boost 1.34.1 Severity: Regression
Keywords: Cc:

Description

From Sean Huang, on the Boost mailing list:

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.

Change History (4)

comment:1 by Douglas Gregor, 15 years ago

Resolution: fixed
Status: newclosed

(In [39240]) function/function_base.hpp, function/function_template.hpp:

  • Switch from dynamic initialization of the vtable pointer to static initialization (Fixes #1260)
  • Handle member pointers properly, only using mem_fn within the invoker to deal with all of the messy bits of calling member pointers

comment:2 by alex_basakov@…, 15 years ago

Can't build 1.34.1 program_options library with newly provided function_base.hpp, function_template.hpp. MSVC 8.0 SP1.

comment:3 by Douglas Gregor, 15 years ago

There is yet another updated function_base.hpp on the main Boost web site. This takes care of the problem for real.

in reply to:  3 comment:4 by baf11@…, 15 years ago

Replying to dgregor:

There is yet another updated function_base.hpp on the main Boost web site. This takes care of the problem for real.

Just wanted to point out the main boost website has a typo -> s/cricial/critical/.

Note: See TracTickets for help on using tickets.