microsoft / microsoft/mimalloc

_Atomic in C++

Open
#1,162 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

When built as C++, `_Atomic` in mimalloc is defined as `std::atomic`. For Clang, `mi_process_attach()` in `prim.c` is declared so it runs before static ctors. The result is that any file level atomic values that happen be set during `mi_process_attach()` are then stomped by the std::atomic ctors, which zero init their values.
For example, in `page-map.c`:
```
static _Atomic(mi_bfield_t) mi_page_map_commit;
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading prim.c around mi_process_attach() and page-map.c around the static mi_page_map_commit declaration, then trace how C++ std::atomic initialization interacts with the attach hook. Confirm the behavior with the existing build or reproduction path for Clang; done means values set during mi_process_attach() are not overwritten by later atomic construction.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.