Boost logo

Boost :

From: Timmo Stange (ts_at_[hidden])
Date: 2007-03-03 23:17:49

Steven Watanabe wrote:

>> Given the relative "distance" between this initialization code and a
>> possible access of either manager or invoker member in the vtable, I
>> think the problem is of a rather academical nature. But the code is
>> still not strictly correct from my understanding.
> I'm afraid that it is a very real problem. In pseudo-code
> if(!vtable_initialized) {
> stored_vtable_initialized = true;
> stored_vtable.vtable_type(f);
> }
> if(stored_vtable.assign_to(f, functor)) vtable = &stored_vtable;
> else vtable = 0;
> Even with a single CPU if the thread is
> interrupted immidiately after the assignment
> to stored_vtable_initialized, another thread
> can reach stored_vtable.assign_to(f, functor)
> before stored_vtable is initialized.

Right, that would be a legal implementation I just did not

This is a little sad since it could probably be easily fixed by
a compiler vendor if the standard would cover it (with a proper
memory model even for the SMP case). But as it is, this nice
little optimization probably has to go.


Timmo Stange

Boost list run by bdawes at, gregod at, cpdaniel at, john at