[ python-Bugs-1512695 ] cPickle.loads() seg.faults when interrupted with keyboard

SourceForge.net noreply at sourceforge.net
Tue Jul 4 01:46:47 CEST 2006


Bugs item #1512695, was opened at 2006-06-26 13:05
Message generated for change (Comment added) made by illume
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1512695&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.5
Status: Closed
Resolution: Fixed
Priority: 7
Submitted By: Faik Uygur (faik)
Assigned to: Neal Norwitz (nnorwitz)
Summary: cPickle.loads() seg.faults when interrupted with keyboard

Initial Comment:
cPickle.loads() gives segmentation fault when 
interrupted with keyboard (CTRL+C). Attached python 
script tested with python version 2.4.3 and 2.5b1.


----------------------------------------------------------------------

Comment By: Rene Dudfield (illume)
Date: 2006-07-03 23:46

Message:
Logged In: YES 
user_id=2042

Sorry... the last post was wrong.

This is the working one:

#define Py_INCREF(op) (			        \
        (assert((op) != NULL)) ,  	        \
        _Py_INC_REFTOTAL  _Py_REF_DEBUG_COMMA	\
        (op)->ob_refcnt++)                      


----------------------------------------------------------------------

Comment By: Rene Dudfield (illume)
Date: 2006-07-03 23:08

Message:
Logged In: YES 
user_id=2042

Hello.

Relating to this bug, I think asserting not NULL in
Py_INCREF would have caught it.

Something like this?

// OLD.
#define Py_INCREF(op) (				\
	_Py_INC_REFTOTAL  _Py_REF_DEBUG_COMMA	\
	(op)->ob_refcnt++)

// NEW.
#define Py_INCREF(op) (				\
	assert((op) != NULL)	\
	_Py_INC_REFTOTAL  _Py_REF_DEBUG_COMMA	\
	(op)->ob_refcnt++)



Cheers.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-06-30 01:19

Message:
Logged In: YES 
user_id=33168

Rene can you produce a patch to address any places you
believe there are problems?  If you can't produce a patch,
at least a bug report with specific areas that are problems
would be helpful.  Thanks.

----------------------------------------------------------------------

Comment By: Rene Dudfield (illume)
Date: 2006-06-30 00:59

Message:
Logged In: YES 
user_id=2042

Py_INCREF should check for NULL with an assert.

All uses of va_arg should be checked to see if they return
NULL... and handle error codes!

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-06-28 06:39

Message:
Logged In: YES 
user_id=33168

I'm impatient and think this fixes the problem.  So I'm
closing this report.  Please re-open if the patch didn't fix
your problem.  (I checked in something slightly different
that the patch attached.)

Committed revision 47139.
Committed revision 47140. (2.4)

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-06-28 06:09

Message:
Logged In: YES 
user_id=33168

Faik, can you see if the attached patch fixes this problem.
 I believe it should.  I can't reproduce the problem with
the patch.

----------------------------------------------------------------------

Comment By: Faik Uygur (faik)
Date: 2006-06-27 08:12

Message:
Logged In: YES 
user_id=1541018

Back trace:

#0  PyTuple_Pack (n=0x3) at Objects/tupleobject.c:149
#1  0xa7b92024 in Instance_New (cls=0xa7bba064, 
args=0xa7c1a43c) 
at /var/tmp/pisi/python-2.4.3-14/work/Python-2.4.3/Modules/cPickle.c:3637
#2  0xa7b93798 in load (self=0xa7c0a80c) 
at /var/tmp/pisi/python-2.4.3-14/work/Python-2.4.3/Modules/cPickle.c:4389
#3  0xa7b953c8 in cpm_loads (self=0x0, args=0x0) 
at /var/tmp/pisi/python-2.4.3-14/work/Python-2.4.3/Modules/cPickle.c:5481
#4  0xa7ec4d97 in PyCFunction_Call (func=0xa7bc9b0c, 
arg=0xa7bc9cec, kw=0x0) at Objects/methodobject.c:108
#5  0xa7efe3d8 in PyEval_EvalFrame (f=0x807e4bc) at 
Python/ceval.c:3563
#6  0xa7f00bb3 in PyEval_EvalCodeEx (co=0xa7bbda60, 
globals=0x0, locals=0x0, args=0xa7bbda60, argcount=0x0, 
kws=0x0, kwcount=0x0, defs=0x0, defcount=0x0, 
closure=0x0) at Python/ceval.c:2736
#7  0xa7f00e35 in PyEval_EvalCode (co=0x0, globals=0x0, 
locals=0x0) at Python/ceval.c:484
#8  0xa7f1ba98 in run_node (n=0xa7bfbe18, filename=0x0, 
globals=0x0, locals=0x0, flags=0x0) at 
Python/pythonrun.c:1265
#9  0xa7f1ce28 in PyRun_SimpleFileExFlags (fp=0x804a008, 
filename=0xaf9ab3b9 "picklefault.py", closeit=0x1, 
flags=0xaf9aafe8) at Python/pythonrun.c:860
#10 0xa7f1d9aa in PyRun_AnyFileExFlags (fp=0x804a008, 
filename=0xaf9ab3b9 "picklefault.py", closeit=0x1, 
flags=0xaf9aafe8) at Python/pythonrun.c:664
#11 0xa7f238d0 in Py_Main (argc=0x1, argv=0xaf9aafe8) at 
Modules/main.c:493
#12 0x0804867a in main (argc=0x0, argv=0x0) at 
Modules/python.c:23


----------------------------------------------------------------------

Comment By: Faik Uygur (faik)
Date: 2006-06-26 14:08

Message:
Logged In: YES 
user_id=1541018

I tracked the seg. fault. It seg. faults in method 
PyTuple_Pack(). When python receives the keyboard 
interrupt:
                o = va_arg(vargs, PyObject *);
                Py_INCREF(o);

va_arg returns NULL, and Py_INCREF causes the seg.fault.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1512695&group_id=5470


More information about the Python-bugs-list mailing list