【发布时间】:2018-06-26 09:18:32
【问题描述】:
我开发了一个小型的 python c 扩展,带有一个 flex 扫描器,在 CPython 中工作得非常好。我所有的测试都通过了。但是在 IPython 中,每当我尝试与我的 c 扩展进行交互时,输出会有所不同,或者 IPython 会因 malloc 错误而死。当我使用 valgrind 运行我的 c 扩展时,在 Py_Initialize() 中发现了很多潜在的内存问题,但它们似乎都与我的代码无关。我还仔细检查了我的对象的引用计数。我在 OS X 和 Python 3.6.5 上使用 anaconda 有人知道可能导致此问题的原因或如何调试此问题吗?
我得到的内存错误是:
python(92795,0x7fff9ba8f380) malloc: *** error for object 0x7f9222845a40: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
【问题讨论】:
标签: python c malloc ipython python-c-api