【问题标题】:IPython behaves differently than CPython when interacting with c extension在与 c 扩展交互时,IPython 的行为与 CPython 不同
【发布时间】: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


    【解决方案1】:

    好吧,这是我自己的愚蠢错误。我的 Python 没有使用 conda env 中的 c 扩展,而是使用了我的 c 扩展的旧版本,无法正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-25
      • 2011-10-07
      • 1970-01-01
      • 1970-01-01
      • 2015-12-11
      • 2011-11-24
      相关资源
      最近更新 更多