python - glibc 检测到 *** python : double free or corruption (! prev) SWIG

标签 python swig glibc

在 SWIG 中为我的 C++ 算法编写了一个包装器之后,当我在导入模块后退出 Python 解释器时,我经常遇到这个错误:

    $ python
    iPython 2.5.6 (r256:88840, Mar 10 2012, 14:05:15) 
    [GCC 4.4.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>from algol import *
    >>> 
    *** glibc detected *** python: double free or corruption (!prev): 0x0000000001e42430 ***

然后我必须按 Ctrl+C 才能取回控制权...发生了什么?

我正在运行以下命令来构建我的 SWIG 包装器:

$NAME=algol
swig -c++ -python $NAME.i
g++ -fpic -c $NAME.cpp $NAME.hpp $NAME\_wrap.cxx -I/usr/local/include/python2.5
g++ -Xlinker -zmuldefs -shared $NAME.o $NAME\_wrap.o -o _$NAME.so

我的 swig 接口(interface)文件只是 algol.hpp 的一个包含:

%module algol
%{
#include "algol.hpp"
%}
%include "algol.hpp"

你怎么看这件事? :S

编辑:在此处附加示例源代码 -> http://pastebin.com/q210vEAs

最佳答案

what is happening?

正是消息所说的:某些代码执行了双重释放,或者其他一些堆损坏。

按照 awoodland 的建议,在 Valgrind 下运行 python,然后查看发生损坏或双重释放的

关于python - glibc 检测到 *** python : double free or corruption (! prev) SWIG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10559791/

相关文章:

python - 更改使用 seaborn.factorplot 创建的条形图中条形的宽度

Python SWIG : convert C++ return parameter to return value, 并将原始 C++ 类型转换为 Python 类型

python - 我应该如何在 RStudio 中优选 "run"Python 脚本?通过运行(使用 reticulate::repl_python()?)或来源?

python3 --version 显示 "NameError: name ' python 3' is not defined"

java - 在模板类中包装 C++ 模板构造函数

python - 绑定(bind) C++ 和 Python 时,SWIG 在使用 MinGW-w64 的 Windows 上不起作用 : DLL load failed while importing: The specified module could not be found

c - 如何 fork 子进程并将程序的所有输出重定向到子进程?

linux - 需要帮助解决 libc-2.23.so 中的段错误

centos7 - 在 CentOS 7 上将 glibc 2.17 升级到 2.19+

Python嵌套列表替换字符串中的unicode字符