简体   繁体   English

与C扩展交互时,IPython的行为不同于CPython

[英]IPython behaves differently than CPython when interacting with c extension

I have developed a small python c-extension, with a flex scanner, that works perfectly fine in CPython. 我开发了一个带有flex扫描器的小型python c-extension,在CPython中工作得很好。 All my tests pass. 我所有的测试都通过了。 But in IPython the output differs or IPython dies with a malloc error, whenever I try to interact with my c-extension. 但是在IPython中,每当我尝试与c-extension交互时,输出都会不同,或者IPython因malloc错误而死亡。 When I run my c-extension with valgrind lots of potential memory issues are detacted in Py_Initialize(), but none of them seem to be related to my code. 当我使用valgrind运行我的c-extension时,Py_Initialize()中发现了很多潜在的内存问题,但是似乎它们都与我的代码无关。 I also double checked the reference count on my objects. 我还仔细检查了对象的引用计数。 I'm using anaconda on OS X with Python 3.6.5 Anybody got an idea what may cause this problem or how to debug this issue? 我在OS X和Python 3.6.5上使用anaconda。有人知道可能导致此问题的原因或如何调试此问题?

The memory error I get is: 我得到的内存错误是:

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

Ok it was my own stupid fault. 好的,这是我自己的愚蠢错误。 I Python didn't used the c extension from the conda env, but an older not properly working version of my c extension. 我的Python没有使用conda env中的c扩展名,而是一个较旧的无法正常工作的c扩展名版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM