python调用.so使用过多出现段错误问题

我用C语言写了一段计算两个python列表相似度的代码,可以使用

python2.7代码(代码正常):

import ctypes
list1 = [[]...]
list2 = [[]...]
tmp = ctypes.cdll.LoadLibrary('./main.so')
lib = tmp.sim
lib.restype = ctypes.c_double
for a in list1:
    for b in list2:
        sim = lib((ctypes.c_char_p * len(a))(*a), (ctypes.c_char_p * len(b))(*b), ctypes.c_int(len(a)), ctypes.c_int(len(b)))
        print sim

当列表比较小的时候程序运行正常,但是当列表比较大的时候,程序运行错误,
C语言的报错信息是:段错误
python的报错信息:Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
试过网上说的方法,没有解决
望大佬能指点一二

阅读 10k
1 个回答

太大了溢出了?大的时候有多大啊

SIGSEGV --- Segment Fault. The possible cases of your encountering this error are: 

1.buffer overflow --- usually caused by a pointer reference out of range. 

2.stack overflow --- please keep in mind that the default stack size is 8192K. 

3.illegal file access --- file operations are forbidden on our judge system.
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题