Opened 5 years ago

Last modified 5 years ago

#13309 new Bugs

function_address_holder::get_module/::get implementations are not thread-safe

Reported by: Daniel Krügler <daniel.kruegler@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.63.0 Severity: Problem
Keywords: Cc:

Description

The discussion in the git review https://github.com/boostorg/filesystem/pull/59#discussion_r152524074 showed that the implementations of function_address_holder::get_module and function_address_holder::get are not completely atomic, because the loop conditions

for(unsigned i = 0; ModuleStates[id] < 2; ++i){

and

for(unsigned i = 0; FunctionStates[id] < 2; ++i){

are not using a read barrier for the variables ModuleStates[id] and FunctionStates[id].

It seems that proper thread-safety using interlocked operations could be realized by emulating an interlocked read-acquire operation via the BOOST_INTERLOCKED_COMPARE_EXCHANGE(&N, 0, 0) idiom.

I can make a concrete pull request if agreement exists on the approach

Change History (1)

comment:1 by Daniel Krügler <daniel.kruegler@…>, 5 years ago

Component: Noneinterprocess
Owner: set to Ion Gaztañaga

The relevant file is boost/interprocess/detail/win32_api.hpp

Note: See TracTickets for help on using tickets.