pyeda
pyeda copied to clipboard
Fix GIL handling in picosat memory allocators.
The custom memory allocators in picosatmodule.c were calling PyMem_Malloc, PyMem_Realloc, and PyMem_Free without holding the GIL. This could lead to a segfault when picosat_sat, which releases the GIL, calls these allocators.
This commit fixes the issue by acquiring the GIL before calling PyMem_ functions and releasing it afterwards in the custom memory allocators.
Fixes #195
The fix was generated using an AI tool (jules). I verified that it works for Python 3.12.2 and Python 3.13.5 (tests do not fail) on MacOS 18.5 (Macbook Pro M1), but I am not an expert on Python memory allocators.