[Python-Dev] head crashing (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Tue May 1 21:07:26 CEST 2007
- Previous message: [Python-Dev] head crashing (was: Fwd: [Python-checkins] buildbot warnings in x86 mvlgcc trunk)
- Next message: [Python-Dev] head crashing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I believe the GIL does not need to be held, but obviously Tim or someone with more memory experience should step in to say definitively.
If you look at Include/pymem.h, PyMemFREE gets defined as PyObjectFREE in a debug build. PyObjectFree is defined at PyObjectDebugFree. That function checks that the memory has not been written with the debug bit pattern and then calls PyObjectFree. That call just sticks the memory back into pymalloc's memory pool which is implemented without using any Python objects. In other words no Python objects are used in pymalloc (to my knowledge)
This is also what I found.
and thus is safe to use without the GIL.
but I got to a different conclusion. If it really goes through the pymalloc pool (obmalloc), then it must hold the GIL while doing so. obmalloc itself is not thread-safe, and relies on the GIL for thread-safety.
In release mode, PyMEM_FREE goes directly to free, which is thread-safe.
Regards, Martin
- Previous message: [Python-Dev] head crashing (was: Fwd: [Python-checkins] buildbot warnings in x86 mvlgcc trunk)
- Next message: [Python-Dev] head crashing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]