This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Seg fault in gcmodule.c
Type: Stage:
Components: Interpreter Core Versions: Python 2.2
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: greg7mdp, nnorwitz, rhettinger
Priority: normal Keywords:

Created on 2003-01-17 17:03 by greg7mdp, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (8)
msg14109 - (view) Author: Gregory Popovitch (greg7mdp) Date: 2003-01-17 17:03
Using Python 2.2.2 on Linux Redhat 7.2:

Python 2.2.2 (#1, Oct 21 2002, 22:19:12) 
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2

I have a crash which happens somewhat randomly (for 
example it goes away if I add a print statement 
somewhere). Here is some gdb info. 

lnx:0:usr/greg/ib> gdb python2.2
GNU gdb Red Hat Linux 7.x (5.0rh-15) (MI_OUT)
Copyright 2001 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 "i386-redhat-linux"...
(gdb) run rules.py > xx
Starting program: /usr/local/bin/python2.2 rules.py > xx
[New Thread 1024 (LWP 30182)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 30182)]
0x080996f8 in visit_decref (op=0x1000000, data=0x0) at 
Modules/gcmodule.c:185
185             if (op && PyObject_IS_GC(op)) {
(gdb) print op
$1 = (PyObject *) 0x1000000
(gdb) print data
$2 = (void *) 0x0
(gdb) where 20
#0  0x080996f8 in visit_decref (op=0x1000000, data=0x0) 
at Modules/gcmodule.c:185
#1  0x080c9abb in dict_traverse (op=0x827bc34, 
visit=0x80996ec <visit_decref>, arg=0x0)
    at Objects/dictobject.c:1589
#2  0x0809897e in collect (young=0x80ee5a0, 
old=0x80ee5ac) at Modules/gcmodule.c:201
#3  0x08099062 in collect_generations () at 
Modules/gcmodule.c:518
#4  0x08099576 in _PyObject_GC_New (tp=0x80f8ae0) at 
Modules/gcmodule.c:879
#5  0x080c7b75 in PyDict_New () at 
Objects/dictobject.c:161
#6  0x080869d5 in symtable_init () at 
Python/compile.c:4671
#7  0x08086910 in symtable_build (c=0xbfffea90, 
n=0x8240e68) at Python/compile.c:4261
#8  0x08084109 in jcompile (n=0x8240e68, 
filename=0x81f83ec "<string>", base=0x0, 
flags=0xbfffebe4)
    at Python/compile.c:4111
#9  0x0808665e in PyNode_CompileFlags (n=0x8240e68, 
filename=0x81f83ec "<string>", flags=0xbfffebe4)
    at Python/compile.c:4042
#10 0x080945c7 in Py_CompileStringFlags (
    str=0x811f8bc "agrepy(\"epreuve photographique\", 22, t, 
len(t), 0, re[0]) and re[1].search(t)", 
    filename=0x81f83ec "<string>", start=258, 
flags=0xbfffebe4) at Python/pythonrun.c:1133
#11 0x080cc4cc in builtin_compile (self=0x0, 
args=0x8241a04) at Python/bltinmodule.c:398
#12 0x080ca7cc in PyCFunction_Call (func=0x8105fb0, 
arg=0x8241a04, kw=0x0) at Objects/methodobject.c:100
#13 0x08077918 in eval_frame (f=0x81a6fbc) at 
Python/ceval.c:2014
#14 0x0807892b in PyEval_EvalCodeEx (co=0x81f8750, 
globals=0x8111ecc, locals=0x0, args=0x82ffe14, 
    argcount=2, kws=0x82ffe1c, kwcount=0, defs=0x0, 
defcount=0, closure=0x0) at Python/ceval.c:2595
#15 0x0807aa43 in fast_function (func=0x815f754, 
pp_stack=0xbfffee14, n=2, na=2, nk=0)
    at Python/ceval.c:3173
#16 0x080779b5 in eval_frame (f=0x82ffc8c) at 
Python/ceval.c:2034
#17 0x0807892b in PyEval_EvalCodeEx (co=0x81f9768, 
globals=0x8111ecc, locals=0x0, args=0x81cc34c, 
    argcount=3, kws=0x81cc358, kwcount=0, defs=0x0, 
defcount=0, closure=0x0) at Python/ceval.c:2595
#18 0x0807aa43 in fast_function (func=0x815f78c, 
pp_stack=0xbfffef74, n=3, na=3, nk=0)
    at Python/ceval.c:3173
#19 0x080779b5 in eval_frame (f=0x81cc1f4) at 
Python/ceval.c:2034
(More stack frames follow...)
msg14110 - (view) Author: Gregory Popovitch (greg7mdp) Date: 2003-01-17 17:05
Logged In: YES 
user_id=222034

I forgot to mention that this program is using the "exec()" builtin 
heavily, and I believe that the crash is related to this.

gregory
msg14111 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-01-17 18:43
Logged In: YES 
user_id=33168

Can you post any code which causes the crash, even if it
only crashes sometimes?
Can you build python with ./configure --with-pydebug and run
your program?  This may find the problem closer to the cause.
msg14112 - (view) Author: Gregory Popovitch (greg7mdp) Date: 2003-01-24 20:46
Logged In: YES 
user_id=222034

It is hard to reproduce... I realized that the bug may be in a 
module I use called AGREPY downloadable from 
http://www.bio.cam.ac.uk/~mw263/pyagrep.html. I tried to 
reproduce my Python 2.2.2 install with "./configure --with-
pydebug" as suggested, but then I get the following error:

/usr/greg/soft/linux/python/Python-2.2.2/python rules.py
Adding parser accelerators ...
Done.
Traceback (most recent call last):
  File "rules.py", line 39, in ?
    import string, os, agrepy
ImportError: /usr/greg/soft/linux/python/Python-
2.2.2/build/lib.linux-i686-2.2/agrepy.so: undefined symbol: 
Py_InitModule4
[6589 refs]

I was mistaken to suspect my use of the "exec" statement, 
which I replaced with "eval" and the problem still happened.

It is not easy to come up with a reasonably small piece of code 
reproducing the problem!

gregory
msg14113 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-01-24 21:01
Logged In: YES 
user_id=33168

After running configure, you must remove all the modules and
rebuild them too.  This doesn't happen by default.  You can
also do rm build/*/*.o build/*/*.so to remove the modules. 
make clean should also work.

Have you tried running valgrind, purify, electric fence, or
some other memory checker on the code.  Perhaps there is a
memory problem in the pyagrep module?
msg14114 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-05-22 21:52
Logged In: YES 
user_id=33168

Gregory, do you still have this problem?  Do you believe
there is a bug or can we close this report?
msg14115 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-07-12 01:25
Logged In: YES 
user_id=80475

Greg, can you also try this with Py2.3b2+.
We're about to release it and need to know if your bug is still 
present.
msg14116 - (view) Author: Gregory Popovitch (greg7mdp) Date: 2003-07-12 02:06
Logged In: YES 
user_id=222034

Sorry, I had responded earlier via email but it didn't make it in 
sourceforge. I was using the module agrepy and I'm sure that 
where the bug is. Since I removed the use of this module from 
my code a few month ago the problem has disapeared. So the 
python code is fine, there is almost certainly a memory error in 
agrepy. 
I make a weak attempt at debugging agrepy but didn't have 
time to follow through.
History
Date User Action Args
2022-04-10 16:06:09adminsetgithub: 37790
2003-01-17 17:03:14greg7mdpcreate