Global Glean object init race with `PRE_INIT_*` patterns
Categories
(Data Platform and Tools :: Glean: SDK, defect)
Tracking
(Not tracked)
People
(Reporter: chutten, Unassigned)
References
Details
Attachments
(1 file)
glean_core
has a pattern in its General APIs that, to handle APIs being called before Glean has been init, we save the provided information to PRE_INIT_
static data, and process it later.
To determine the difference between "before Glean has been init" and "later", we use was_initialize_called
. If it has, we assume it's "later" so we can call with_glean(_mut)
.
However, this creates a race where initialize has been called (and the "glean.init" thread spawned, and so forth), but the global Glean
object has not yet been set up (ie, setup_glean
has yet to return (or even be called) in the "glean.init" thread).
A more correct and safer definition of "later" would be to check if the Global Glean
has been initialized. An actually correct and safe one would be to check if the PRE_INIT_
static data has been consumed.
Reporter | ||
Updated•2 months ago
|
Comment 2•2 months ago
|
||
Reporter | ||
Comment 3•2 months ago
|
||
chutten merged PR [mozilla/glean]: bug 1959771 - Ensure there's a global Glean before using it (#3109) in 9632ebb.
Description
•