зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1858250 - malloc_initialized should not be SequentiallyConsistent. r=glandium
I think ReleaseAcquire semantics are sound here. It might be that relaxed is fine too, but that might be technically unsound because it could make the writes in malloc_init_hard not visible to the other threads in time. Depends on D190623 Differential Revision: https://phabricator.services.mozilla.com/D190624
This commit is contained in:
Родитель
b8877f2bfb
Коммит
a3e8abd326
|
@ -639,7 +639,7 @@ static void* base_alloc(size_t aSize);
|
|||
// threads are created.
|
||||
static bool malloc_initialized;
|
||||
#else
|
||||
static Atomic<bool, SequentiallyConsistent> malloc_initialized;
|
||||
static Atomic<bool, MemoryOrdering::ReleaseAcquire> malloc_initialized;
|
||||
#endif
|
||||
|
||||
static StaticMutex gInitLock MOZ_UNANNOTATED = {STATIC_MUTEX_INIT};
|
||||
|
@ -1518,10 +1518,9 @@ FORK_HOOK void _malloc_postfork_child(void);
|
|||
// initialization.
|
||||
// Returns whether the allocator was successfully initialized.
|
||||
static inline bool malloc_init() {
|
||||
if (malloc_initialized == false) {
|
||||
if (!malloc_initialized) {
|
||||
return malloc_init_hard();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3492,7 +3491,7 @@ class AllocInfo {
|
|||
template <bool Validate = false>
|
||||
static inline AllocInfo Get(const void* aPtr) {
|
||||
// If the allocator is not initialized, the pointer can't belong to it.
|
||||
if (Validate && malloc_initialized == false) {
|
||||
if (Validate && !malloc_initialized) {
|
||||
return AllocInfo();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче