- Using the following env vars to reproduce
$ PYTHONMALLOC=debug PYTHONTRACEMALLOC=1 python3 test_rtaudio_min.py
RtAudio Version 6.0.1
RtAudio_new: start.
RtAudio_new: api==NULL.
RtAudio_new: end.
RtAudio_init.
RtAudio_dealloc: start.
RtAudio_dealloc: self->dac
RtAudio_dealloc: pre: delete self->dac
RtAudio_dealloc: post: delete self->dac
RtAudio_dealloc: pre: Py_TYPE(self)->tp_free((PyObject*)self)
Debug memory block at address p=0x102d10440: API 'o'
8 bytes originally requested
The 7 pad bytes at p-7 are FORBIDDENBYTE, as expected.
The 8 pad bytes at tail=0x102d10448 are not all FORBIDDENBYTE (0xfd):
at tail+0: 0xa0 *** OUCH
at tail+1: 0x60 *** OUCH
at tail+2: 0xf9 *** OUCH
at tail+3: 0x02 *** OUCH
at tail+4: 0x01 *** OUCH
at tail+5: 0x00 *** OUCH
at tail+6: 0x00 *** OUCH
at tail+7: 0x00 *** OUCH
Data at p: 00 00 00 00 00 00 00 00
Memory block allocated at (most recent call first):
File "/Users/sa/projects/python-rtaudio/build/test_rtaudio_min.py", line 3
Fatal Python error: _PyMem_DebugRawFree: bad trailing pad byte
Python runtime state: finalizing (tstate=0x00000001034bfd28)
Current thread 0x00007ff8562ab700 (most recent call first):
<no Python frame>
Abort trap: 6
- trying again with with debug python
$ cd /Python-3.11.7
$ mkdir debug && cd debug
$ ../configure --with-pydebug --prefix=$HOME/projects/python-rtaudio/python
$ make install EXTRA_CFLAGS="-DPy_DEBUG"
-
https://github.com/python/cpython/blob/main/Modules/zlibmodule.c
-
https://geghamjivanyan.medium.com/c-c-extension-for-python-f68444dab472
-
https://docs.python.org/3/c-api/init.html#thread-state-and-the-global-interpreter-lock
-
https://pythonextensionpatterns.readthedocs.io/en/latest/thread_safety.html
cython can't handle std::function
directly, here are some links to workarounds: