重新审视核心转储 [英] Core dump revisited

查看:82
本文介绍了重新审视核心转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个使用C扩展的python脚本。我不断得到一个重复出现的问题,导致核心转储在C />
扩展返回数据后返回tp python几行。我尝试使用pbd和gdb,但是我没有成功地理解出了什么问题以及在哪里。我发布了

这里的python脚本是错误消息和gdb输出之后

读取核心文件:

...... printout来自C扩展....

完成释放2D阵列。

现在释放1D阵列

释放1D阵列

释放15km阵列

完成

将数据返回给Python!

在python中:将元组数据分配给数值数组!

时间做沿海效应

分段故障(核心倾倒)

.......


现在,在时间做沿海效应之后的下一步从来没有执行过
。即使我在另一个打印声明中出现相同的

事情。我正在使用python 2.3并且我已将stacksize设置为

无限制。当用gdb读取核心转储文件时,我得到:


gdb msgppscomp.py core.3203

GNU gdb 6.0-2mdk(Mandrake Linux)

版权所有2003 Free Software Foundation,Inc。

GDB是免费软件,由GNU通用公共许可证承保,并且

你是

欢迎在某些

条件下更改和/或分发它的副本。

键入show copying查看条件。

GDB绝对没有保修。输入show warranty for

详情。

此GDB配置为

" i586-mandrake-linux-gnu" ..." / data / proj_ns1 / safworks / sheldon / msgppscomp.py":

不是可执行格式:文件格式无法识别


核心是由`python msgppscomp.py'生成的'。

程序以信号11终止,分段错误。

#0 0x40079dfa在? ()

(gdb)


..................

我不太熟悉使用gdb和python和C扩展。我想b $ b想知道问题可能出在哪里。我有

确保在退出之前释放C扩展中的所有数组,所以我怀疑这可能是问题所在。这是python

脚本:


#!/ usr / bin / env python

#! - * - 编码: UTF-8 - * -


class WriteHdfFile:


def __init __(self,outfile):


self.outfile = outfile

self.COMPRESS_LVL = 6

def writeAreainfo(self):

import _pyhl

导入系统

sys.float_output_precision = 2

aList = _pyhl.nodelist()

aNode = _pyhl.node(_pyhl.GROUP_ID," / PPS_MSG_COMP")

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / LAT")

aNode.setArrayValue(1,lat.shape,lat," float", - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / LON&qu​​ot;)

aNode.setArrayValue(1,lon.shape,lon," float", - 1)
aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / VALCONCEN")

aNode.setArrayValue(1,valconcen .shape,v alconcen,i nt, - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / LIGHTCON&qu​​ot;)

aNode.setArrayValue(1,lightcon.shape,lightcon,< flo at", - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / BIAS100")

aNode.setArrayValue(1,bias100.shape,bias100," float", - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / BIAS75")

aNode.setArrayValue(1,bias75.shape ,bias75,float, - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / BIAS50")

aNode.setArrayValue(1,bias50.shape,bias50," float", - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / BIAS25")

aNode.setArrayValue(1,bias25.shape,bias25," float", - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / COAST&q uot;)

aNode.setArrayValue(1,coast.shape,coast," float", - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / STATISTICS")

aNode.setArrayValue(1,stats.shape,stats," int", - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / PERCENTAGE")

aNode.setArrayValue(1,百分比.shape,percentage," float",1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / VA_vs_BIAS" )

aNode.setArrayValue(1,va_area.shape,va_area," float", - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.DATASET_ID," / VANUM")

aNode.setArrayValue(1,vanum.shape,vanum," float", - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.ATTRIBUTE_ID," / NSCENES")

aNode.setScalarValue(-1,areascenes ,int, - 1)

aList.addNode(aNode)

aNode = _pyhl.node(_pyhl.ATTRIBUTE_ID," / SATELLITE")

aNode.setScalarValue(-1,satid," string", - 1)

aList.addNode(aNode)


self.status = aList.write(self.outfile,self.COMPRESS_LVL)


返回self.status


#------------------------------------- -------------------------------------------------- ------------------------------------

if __name__ ==" __main __":
来自数字导入的
*

导入sys,os,string,math,glob

导入msgppsarea,msgppscoast

进口货架

date = str(200510)

#date = sys.argv [1]

#s = sys.argv [2]

cp =''cfc''

global

valconcen,bias100,bias75,lightcon,bias50,bias25,pe rcentage, va_area,lat,lon

全球统计,areacenes,satid,vanum,coast

valconcen = zeros((324,243),''我')

bias100 =零((324,243),''f' )

bias75 =零((324,243),''f'')

lightcon =零((324,243),''f'')

bias50 =零((324,243),''f'')

bias25 =零((324,243),''f'')

coast = zeros ((324,243),''f'')

百分比=零((60,1),''f'')

va_area =零((90, 1),''f'')

vanum =零((90,1),''f'')

lat = zeros((324,243),' 'f'')

lon =零((324,243),''f'')

stats =零((60,1),''我'' )

d =

shelve.open(" / data / proj / safworks / sheldon / MSG_PPS_COMP / c_codes /" +" _" + date +"。 shelve")

msglist = d [" Area.msglist"]

tilescenes = d [" Area.tilescenes"]

tiles = d [" Area.tiles"]

ppslist = d [" Area.ppslist"]

lllist = d [" Area.lllist"]

areascenes = d [" Area.areascenes"]

d.close()

print"删除文件指针并调用C函数"

RES =

msgppsarea.msgppsarea(tilescenes,tiles,msglist,pps list,lllist,int(date),areascenes)

print" ;在python中:将元组数据分配给数值数组!

for x in range(324):

bias100 [x] =(RES [0])[x * 243:x * 243 + 243]

bias75 [x] =(RES [1])[x * 243:x * 243 + 243]

bias50 [x ] =(RES [2])[x * 243:x * 243 + 243]

bias25 [x] =(RES [3])[x * 243:x * 243 + 243]

lat [x] =(RES [4])[x * 243:x * 243 + 243]

lon [x] =(RES [5])[x * 243:x * 243 + 243]

lightcon [x] =(RES [6])[x * 243:x * 243 + 243]

valconcen [x ] =(RES [7])[x * 243:x * 243 + 243]

范围内的x(90):

va_area [x] =(RES [10])[x]

vanum [x] =(RES [11])[x]

for x in range(60):

stats [x] =(RES [8])[x]

百分比[x] =(RES [9 ])[x]

打印时间做沿海效应

RES = msgppscoast.msgppscoast(ravel(bias100),瓷砖)

范围内的$ b(324):

coast [x] =(RES [0])[x * 243:x * 243 + 243]

outfile =

" / data / proj / safworks / sheldon / MSG_PPS_COMP / results /" +''CFC''+''_''+''_''+

date +''。h5''

打印输出文件

chk = WriteHdfFile(outfile)

res = chk.writeAreainfo()

print" File written!"

print" Complete!"

************ ********************


C扩展非常大,所以如果有人想要的话我会把它包括在内>
看到它。


感谢您的任何建议,


Sheldon

Hi,

I have a python script that uses a C extention. I keep getting a
recurring problem that causes a core dump a few lines after the C
extention return data back tp python. I tried using pbd and gdb but I
have not succeeded in understanding what went wrong and where. I post
the python script here is the error message and gdb output after
reading the core file:
...... printout from with C extention....
Completed freeing 2D arrays.
Now freeing 1D arrays
freed 1D arrays
freeing 15km arrays
Complete
Returning data back to Python!
In python: assigning tuple data to numeric arrays!
Time to do the coastal effects
Segmentation fault (core dumped)
.......

Now there next step after "Time to do the coastal effects" was never
executed. And even if I put another print statement there the same
thing happens. I am using python 2.3 and I have set my stacksize to
unlimited. When reading the core dump file with gdb I get:

gdb msgppscomp.py core.3203
GNU gdb 6.0-2mdk (Mandrake Linux)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as
"i586-mandrake-linux-gnu"..."/data/proj_ns1/safworks/sheldon/msgppscomp.py":
not in executable format: File format not recognized

Core was generated by `python msgppscomp.py''.
Program terminated with signal 11, Segmentation fault.
#0 0x40079dfa in ?? ()
(gdb)

..................

I am not very familiar with using gdb with python and C extentions. I
would like to get some ideas about where the problem might be. I have
made sure that all the arrays in the C extention are freed before
exiting so I doubt that this might be the problem. Here is the python
script:

#!/usr/bin/env python
#!-*-coding: UTF-8 -*-

class WriteHdfFile:

def __init__(self,outfile):

self.outfile = outfile
self.COMPRESS_LVL = 6

def writeAreainfo(self):
import _pyhl
import sys
sys.float_output_precision = 2

aList = _pyhl.nodelist()
aNode = _pyhl.node(_pyhl.GROUP_ID,"/PPS_MSG_COMP")
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/LAT")
aNode.setArrayValue(1,lat.shape,lat,"float",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/LON")
aNode.setArrayValue(1,lon.shape,lon,"float",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/VALCONCEN")
aNode.setArrayValue(1,valconcen.shape,valconcen,"i nt",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/LIGHTCON")
aNode.setArrayValue(1,lightcon.shape,lightcon,"flo at",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/BIAS100")
aNode.setArrayValue(1,bias100.shape,bias100,"float ",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/BIAS75")
aNode.setArrayValue(1,bias75.shape,bias75,"float",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/BIAS50")
aNode.setArrayValue(1,bias50.shape,bias50,"float",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/BIAS25")
aNode.setArrayValue(1,bias25.shape,bias25,"float",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/COAST")
aNode.setArrayValue(1,coast.shape,coast,"float",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/STATISTICS")
aNode.setArrayValue(1,stats.shape,stats,"int",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/PERCENTAGE")
aNode.setArrayValue(1,percentage.shape,percentage, "float",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/VA_vs_BIAS")
aNode.setArrayValue(1,va_area.shape,va_area,"float ",-1)
aList.addNode(aNode)
aNode=_pyhl.node(_pyhl.DATASET_ID,"/VANUM")
aNode.setArrayValue(1,vanum.shape,vanum,"float",-1)
aList.addNode(aNode)
aNode = _pyhl.node(_pyhl.ATTRIBUTE_ID,"/NSCENES")
aNode.setScalarValue(-1,areascenes,"int",-1)
aList.addNode(aNode)
aNode = _pyhl.node(_pyhl.ATTRIBUTE_ID,"/SATELLITE")
aNode.setScalarValue(-1,satid,"string",-1)
aList.addNode(aNode)

self.status = aList.write(self.outfile,self.COMPRESS_LVL)

return self.status

#---------------------------------------------------------------------------------------------------------------------------
if __name__ == "__main__":
from Numeric import *
import sys, os, string, math, glob
import msgppsarea,msgppscoast
import shelve
date = str(200510)
#date = sys.argv[1]
#s = sys.argv[2]
cp = ''cfc''
global
valconcen,bias100,bias75,lightcon,bias50,bias25,pe rcentage,va_area,lat,lon
global stats,areascenes,satid,vanum,coast
valconcen = zeros((324,243),''i'')
bias100 = zeros((324,243),''f'')
bias75 = zeros((324,243),''f'')
lightcon = zeros((324,243),''f'')
bias50 = zeros((324,243),''f'')
bias25 = zeros((324,243),''f'')
coast = zeros((324,243),''f'')
percentage = zeros((60,1),''f'')
va_area = zeros((90,1),''f'')
vanum = zeros((90,1),''f'')
lat = zeros((324,243),''f'')
lon = zeros((324,243),''f'')
stats = zeros((60,1), ''i'')
d =
shelve.open("/data/proj/safworks/sheldon/MSG_PPS_COMP/c_codes/"+"_"+date+".shelve")
msglist = d["Area.msglist"]
tilescenes = d["Area.tilescenes"]
tiles = d["Area.tiles"]
ppslist = d["Area.ppslist"]
lllist = d["Area.lllist"]
areascenes = d["Area.areascenes"]
d.close()
print "Deleting file pointer and calling C function"
RES =
msgppsarea.msgppsarea(tilescenes,tiles,msglist,pps list,lllist,int(date),areascenes)
print "In python: assigning tuple data to numeric arrays!"
for x in range(324):
bias100[x] = (RES[0])[x*243:x*243+243]
bias75[x] = (RES[1])[x*243:x*243+243]
bias50[x] = (RES[2])[x*243:x*243+243]
bias25[x] = (RES[3])[x*243:x*243+243]
lat[x] = (RES[4])[x*243:x*243+243]
lon[x] = (RES[5])[x*243:x*243+243]
lightcon[x] = (RES[6])[x*243:x*243+243]
valconcen[x] = (RES[7])[x*243:x*243+243]
for x in range(90):
va_area[x] = (RES[10])[x]
vanum[x] = (RES[11])[x]
for x in range(60):
stats[x] = (RES[8])[x]
percentage[x] = (RES[9])[x]
print "Time to do the coastal effects"
RES = msgppscoast.msgppscoast(ravel(bias100),tiles)
for x in range(324):
coast[x] = (RES[0])[x*243:x*243+243]
outfile =
"/data/proj/safworks/sheldon/MSG_PPS_COMP/results/"+''CFC''+''_''+ ''_'' +
date + ''.h5''
print outfile
chk = WriteHdfFile(outfile)
res = chk.writeAreainfo()
print "File written!"
print "Complete!"
********************************

The C extention is very large so I will include it if anyone wants to
see it.

Thanks for any advice,

Sheldon

推荐答案

On 17 dic,07:01," Sheldon" < shejo ... @ gmail.comwrote:
On 17 dic, 07:01, "Sheldon" <shejo...@gmail.comwrote:

我有一个使用C扩展的python脚本。我不断得到一个重复出现的问题,导致核心转储在C />
扩展返回数据后返回tp python几行。我尝试使用pbd和gdb但是我
I have a python script that uses a C extention. I keep getting a
recurring problem that causes a core dump a few lines after the C
extention return data back tp python. I tried using pbd and gdb but I



很可能错误是在C扩展中,而不是在Python代码中。

联系作者。


-

Gabriel Genellina

Most probably the error is inside the C extension, not in Python code.
Contact the author.

--
Gabriel Genellina


Sheldon< sh ** **** @ gmail.com写道:
Sheldon <sh******@gmail.comwrote:

gdb msgppscomp.py core.3203
gdb msgppscomp.py core.3203



运行


gdb python


然后输入


运行msgppscomp.py

在gdb提示符下。


当它崩溃时,输入bt用于回溯。这将确定

到底崩溃的地方。


希望这会让事情更加清晰。如果不发布输出。


-

Nick Craig-Wood< ni ** @ craig-wood.com-- http://www.craig-wood.com/nick




Nick Craig-Wood skrev:

Nick Craig-Wood skrev:

Sheldon< sh ****** @ gmail。 comwrote:
Sheldon <sh******@gmail.comwrote:

gdb msgppscomp.py core.3203
gdb msgppscomp.py core.3203



运行


gdb python


然后键入


运行msgppscomp.py


at the gdb提示。


当它崩溃时,输入bt用于回溯。这将确定

到底崩溃的地方。


希望这会让事情更加清晰。如果不发布输出。


-

Nick Craig-Wood< ni ** @ craig-wood.com-- http://www.craig-wood.com/nick



很棒!现在我知道如何在python中使用gdb。结果区域

发布在下面。由于我是新手,我可以在

解释问题时使用一些帮助。我所知道的是:我对

数组的分配是好的,但是在释放数组时会出现问题。问题

如下所示,但由于我是CI的新人,确定可以使用一些

帮助。


收到的节目信号SIGSEGV,分段故障。

[切换到线程1077321856(LWP 32710)]
来自/lib/tls/libc.so.6的mallopt()中的
0x40297b83 />
(gdb)bt

#0 0x40297b83来自/lib/tls/libc.so.6的mallopt()

#1 0x402958ba免费( )来自/lib/tls/libc.so.6

#2 0x405e070a in MemoryFreeOrd()at msgppsmodule_area.c:1675

#3 0x405dae0a in msgppsarea(self = 0x0) ,args = 0x4042aa7c,kwargs = 0x0)

msgppsmodule_area.c:328

到目前为止,我感谢您的帮助,可以使用更多。


/ S

Wonderful! Now I know how to used gdb with python. The are results area
posted below. Since I am new at this I could used some help in
interpreting the problem. What I do know is this: my allocation of the
array is good but when freeing the array, a problem arises. The problem
is given below but since I am new as well to C I sure could use some
help.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1077321856 (LWP 32710)]
0x40297b83 in mallopt () from /lib/tls/libc.so.6
(gdb) bt
#0 0x40297b83 in mallopt () from /lib/tls/libc.so.6
#1 0x402958ba in free () from /lib/tls/libc.so.6
#2 0x405e070a in MemoryFreeOrd () at msgppsmodule_area.c:1675
#3 0x405dae0a in msgppsarea (self=0x0, args=0x4042aa7c, kwargs=0x0) at
msgppsmodule_area.c:328
#4 0x40073b16 in PyCFunction_Call () from /usr/lib/libpython2.3.so.1.0
I appreciate your help so far and could use some more.

/S

这篇关于重新审视核心转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆