mirror of
https://github.com/deepseek-ai/3FS.git
synced 2026-11-05 00:47:47 +00:00
[PR #376] fix: Remove race condition in memory allocator initialization #398
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/3FS#398
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/3FS/pull/376
Author: @yurekami
Created: 1/4/2026
Status: 🔄 Open
Base:
main← Head:fix/memory-allocator-race-condition📝 Commits (1)
5e76874fix: Remove race condition in memory allocator initialization📊 Changes
1 file changed (+2 additions, -9 deletions)
View changed files
📝
src/memory/common/GlobalMemoryAllocator.cc(+2 -9)📄 Description
Summary
gAllocatorInitedflag that caused a race conditionstd::call_oncewhich provides proper thread-safety guaranteesProblem
The original code had a race condition in
GlobalMemoryAllocator.cc:Issues:
gAllocatorInitedis a plainbool, not atomic - no synchronizationgAllocatorInited = truecan execute beforestd::call_oncefully completesgAllocatorInited = truewhilegAllocatoris still uninitializedSolution
Remove the redundant flag and rely solely on
std::call_once:Why this works:
std::call_onceprovides full happens-before guarantees (C++11 standard)call_oncebecomes a fast single atomic load (efficient fast-path)Test plan
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.