Skip to content

Commit

Permalink
add note about MacOS malloc warnings for tsan build (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoldbaum authored Jan 5, 2025
1 parent 2f6a95a commit 00fa860
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,21 @@ PYTHON_GIL=0 python -c "import sys; print(sys._is_gil_enabled())"
cd ..
```

!!! note
On MacOS, you may see messages like this when you start Python:

```
python(7027,0x1f6dfc240) malloc: nano zone abandoned due to inability to reserve vm space.
```

This message is being emmitted by the MacOS malloc implementation. As
[explained
here](https://stackoverflow.com/questions/64126942/malloc-nano-zone-abandoned-due-to-inability-to-preallocate-reserved-vm-space),
this happens for any program compiled with thread sanitizer on MacOS and can
be safely ignored by setting the `MallocNanoZone` environment variable to
0\. You should only set this in session you are running thread sanitizer
under, as this setting will slow down other programs that allocate memory.

### Compile NumPy with TSAN

- Get the source code (for example, the `main` branch)
Expand All @@ -336,13 +351,7 @@ python -m pip install -U git+https://github.com/cython/cython
- Build the package

```bash
export CC=clang-18
export CXX=clang++-18
export CFLAGS=-fsanitize=thread
export CXXFLAGS=-fsanitize=thread
export LDFLAGS=-fsanitize=thread

python -m pip install -v . --no-build-isolation
CC=clang-18 CXX=clang++-18 python -m pip install -v . --no-build-isolation -Csetup-args=-Db_sanitize=thread
```

### Useful TSAN options
Expand Down

0 comments on commit 00fa860

Please sign in to comment.