Commit f93c48dc authored by A. Unique TensorFlower's avatar A. Unique TensorFlower Committed by TensorFlower Gardener
Browse files

Use LINKER_INITIALIZED for mutexes with static storage class.

This was causing exit-time races as some threads were accessing the
mutex as it was being destructed.

			---------------

It is illegal to use any static type with a constructor/destructor with static
storage class in a multithreaded C++ programme that can exit(), even if the
constructor is protected by C++11's function-scope static initialization rules,
because exit-time destruction is unsafe in the presence of multiple threads.

For things that are not function-scope, the construction is also unsafe,
because global contruction ordering is undefined in general.

The LINKER_INITIALIZED variant constructor for TensorFlow's mutex avoids these
problems, at the cost of relying on the linker to zero-initialize the BSS
region.

PiperOrigin-RevId: 176612772
parent ef3ee202
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment