pyeda icon indicating copy to clipboard operation
pyeda copied to clipboard

Fix GIL handling in picosat memory allocators.

Open ykazakov opened this issue 6 months ago • 1 comments

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

ykazakov avatar Jun 25 '25 08:06 ykazakov

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.

ykazakov avatar Jun 25 '25 09:06 ykazakov