From: DierkErdmann on
Hi,

my python project crashes in a non reproducible way. With gdb I got
the backtraces given below.
How can I possibly figure out the reason for the segfaults that occur
under Linux and Windows, using Python 2.6 in both cases.

Thanks
Dierk


Program received signal SIGSEGV, Segmentation fault.
0x080902bf in dict_dealloc (mp=0xbfbf0b4) at ../Objects/dictobject.c:
911
911 ../Objects/dictobject.c: No such file or directory.
in ../Objects/dictobject.c
(gdb) bt
#0 0x080902bf in dict_dealloc (mp=0xbfbf0b4) at ../Objects/
dictobject.c:911
#1 0x08090304 in dict_dealloc (mp=0xa805d74) at ../Objects/
dictobject.c:911
#2 0x08090304 in dict_dealloc (mp=0xbc2768c) at ../Objects/
dictobject.c:911
#3 0x08090304 in dict_dealloc (mp=0xbc27c64) at ../Objects/
dictobject.c:911
#4 0x080ab611 in subtype_dealloc (self=
<Graph(node={u'(truncated)) at ../Objects/typeobject.c:1004
#5 0x08090304 in dict_dealloc (mp=0x9d3624c) at ../Objects/
dictobject.c:911
#6 0x0806c88b in instance_dealloc (inst=0x96641ec)
at ../Objects/classobject.c:668
#7 0x080dd1ad in PyEval_EvalFrameEx (f=
---Type <return> to continue, or q <return> to quit---
Frame 0x969ddb4, for file analyse.py, line 398, in analyseall
(options=<Values(create_diagrams=True) at remote 0x966406c>,
TIMEFMT='%d.%m.%Y', TIMESPAN_DAYS=365, projects=[('ant', 2002, 2008),
('apache', 1995, 2009), ('gcc', 2003, 2009), ('gimp', 2003, 2009),
('gnucash', 2001, 2009), ('gnumeric', 2000, 2009), ('gtk', 2000,
2009), ('kde', 2003, 2009), ('maemo', 2006, 2009), ('python', 1999,
2009), ('samba', 2004, 2009), ('tomcat', 2000, 2009), ('wine', 2003,
2009)],
ra=<RegrAnalyzer(tseries=[<Timeseries(results_hash={<datetime.date at
remote 0x9773b00>: {'grClusterCoeff': <float at remote 0x97e0b8c>,
'grDensity': <float at remote 0x97e0b4c>, 'grNumberMails': 1593,
'mailsPerDay': <float at remote 0x97e0b7c>, 'grMedianDegree':
<numpy.float64 at remote 0x9695a50>, 'productivity': <float at remote
0x97e0b6c>, 'grDistKSTest': <numpy.float64 at remote 0x947e410>,
'grEdges': 269, 'grBetweenCentNetw': <float at remote 0x97e0b5c>,
'grNumberNodes': 122, 'grBetweenCentNodeMedian': <numpy.float64 at
remote 0x93581e0>, 'gr...(truncated), throwflag=0) at ../Python/
ceval.c:1010
#8 0x080e1bb0 in fast_function (f=
Frame 0x82eda8c, for file analyse.py, line 472, in <module> (),
throwflag=0) at ../Python/ceval.c:3836
#9 call_function (f=
Frame 0x82eda8c, for file analyse.py, line 472, in <module> (),
throwflag=0) at ../Python/ceval.c:3771
#10 PyEval_EvalFrameEx (f=
Frame 0x82eda8c, for file analyse.py, line 472, in <module> (),
throwflag=0) at ../Python/ceval.c:2412


Program received signal SIGSEGV, Segmentation fault.
visit_decref (op=<unknown at remote 0x20000>, data=0x0) at ../Modules/
gcmodule.c:271
271 ../Modules/gcmodule.c: No such file or directory.
in ../Modules/gcmodule.c
(gdb) bt
#0 visit_decref (op=<unknown at remote 0x20000>, data=0x0) at ../
Modules/gcmodule.c:271
#1 0x0809223d in dict_traverse (op=
{'_sa_adapter': <CollectionAdapter(_data=<weakref at remote
0x1db90734>, owner_state=<InstanceState(obj=<weakref at remote
0xae4de3c>, _strong_obj=None, callables={}, session_id=158970732,
modified=False,
class_=<EntityMeta(mapper=<Mapper(primary_key_argument=None,
inherits=None, _all_tables=set([<...>]), _validators={},
_inheriting_mappers=set([]), _with_polymorphic_selectable=<...>,
single=False, allow_partial_pks=True,
_dependency_processors=[<DetectKeySwitch(mapper=<...>,
direction=<symbol(name='MANYTOONE') at remote 0x8605b2c>,
parent=<Mapper(primary_key_argument=None, inherits=None,
_all_tables=set([<...>]), _validators={}, _inheriting_mappers=set([]),
single=False, allow_partial_pks=True, _dependency_processors=[],
tables=[<...>], order_by=False,
primary_key=<ColumnSet(_list=[<Column(proxy_set=set([<...>]),
index=None, server_onupdate=None, name='id', is_literal=False,
nullable=False, default=None, quote=None, autoincrement=True,
onupdate=None, foreign_keys=<OrderedSet(_list=[]) at remote
0x96d7554>, _...(truncated), visit=0x810c460 <visit_decref>, arg=0x0)
at ../Objects/dictobject.c:2003
#2 0x0810cebc in subtract_refs (generation=<value optimised out>)
at ../Modules/gcmodule.c:296
#3 collect (generation=<value optimised out>) at ../Modules/
gcmodule.c:817
#4 0x0810d8eb in collect_generations (basicsize=28) at ../Modules/
gcmodule.c:924
#5 _PyObject_GC_Malloc (basicsize=28) at ../Modules/gcmodule.c:1363
#6 0x080ab65b in PyType_GenericAlloc (type=0x8236be0, nitems=0) at ../
Objects/typeobject.c:758
#7 0x080bc9a7 in weakref___new__ (type=0x8236be0, args=
(<Message at remote 0x2526e38c>, <instancemethod at remote
0x2526ab6c>), kwargs=0x0)
at ../Objects/weakrefobject.c:300
#8 0x080ad0dd in type_call (type=0x8236be0, args=
(<Message at remote 0x2526e38c>, <instancemethod at remote
0x2526ab6c>), kwds=0x0)
at ../Objects/typeobject.c:726
#9 0x0806245a in PyObject_Call (func=<type at remote 0x8236be0>, arg=
(<Message at remote 0x2526e38c>, <instancemethod at remote
0x2526ab6c>), kw=0x0)
at ../Objects/abstract.c:2492
#10 0x080e0471 in do_call (f=
Frame 0x9aabb04, for file /usr/local/lib/python2.6/dist-packages/
SQLAlchemy-0.6.0-py2.6.egg/sqlalchemy/orm/state.py, line 29, in
__init__
(self=<InstanceState(class_=<EntityMeta(inreplytostr=<InstrumentedAttribute(parententity=<Mapper(primary_key_argument=None,
inherits=None, _all_tables=set([<...>]), _validators={},
_inheriting_mappers=set([]), _with_polymorphic_selectable=<...>,
single=False, allow_partial_pks=True,
_dependency_processors=[<DetectKeySwitch(mapper=<...>,
direction=<symbol(name='MANYTOONE') at remote 0x8605b2c>,
parent=<...>, post_update=False, passive_updates=True,
prop=<RelationshipProperty(key='inreplyto', synchronize_pairs=[(<...>,
<...>)], _compile_finished=True, lazy=True, uselist=False,
collection_class=None, back_populates=None, table=<...>,
innerjoin=False, order_by=False, join_depth=None,
strategy=<LazyLoader(mapper=<...>, target=<...>, parent=<...>,
use_get=True, uselist=False,
_LazyLoader__lazywhere=<_BinaryExpression(negate=<built-in function
ne>, modifiers={}, right=<...>, opera...(truncated), throwflag=0)
at ../Python/ceval.c:3968

From: Paul Rubin on
"DierkErdmann(a)mail.com" <DierkErdmann(a)mail.com> writes:
> my python project crashes in a non reproducible way. With gdb I got
> the backtraces given below.
> How can I possibly figure out the reason for the segfaults that occur
> under Linux and Windows, using Python 2.6 in both cases.

It's a big C program and you have to debug it as one. Well, first of
all try upgrading to the newest versions and see if there is already a
fix. Be especially suspicious of any C extension modules you're using.
There are also some compile time options that let you rebuild Python
with extra consistency checks for reference counts. Turn those on and
see what happens.
From: Christian Heimes on
> my python project crashes in a non reproducible way. With gdb I got
> the backtraces given below.
> How can I possibly figure out the reason for the segfaults that occur
> under Linux and Windows, using Python 2.6 in both cases.

One of your third party C extension has a reference count bug. It looks
like it has an Py_INCREF() to little or a Py_DECREF() too much. The
first segfaults occurs in a decref macro:

Objects/dictobject.c:911
Py_XDECREF(ep->me_value);

, the second is a bit more obscure and hidden in the cyclic GC. The
error is either introduced by the same reference counting bug or in
error in the type definition and initialization.

Which third party products with C extensions do you use? Have you
updated your database adapter and NumPy yet?

Christian

From: DierkErdmann on
On 8 Jul., 19:32, Christian Heimes <li...(a)cheimes.de> wrote:
> Which third party products with C extensions do you use? Have you
> updated your database adapter and NumPy yet?

I'm using sqlalchemy, scipy and numpy. I will try to update these and
see if that helps.

Dierk