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.

Author amaury.forgeotdarc
Recipients amaury.forgeotdarc, isandler, pitrou
Date 2010-11-21.09:25:34
SpamBayes Score 1.6581746e-06
Marked as misclassified No
Message-id <1290331536.35.0.544665734609.issue10478@psf.upfronthosting.co.za>
In-reply-to
Content
I reproduce the problem, see the call stack below.
The issue is in the io module: the function _bufferedwriter_flush_unlocked() runs with the file mutex already acquired, but it calls PyErr_CheckSignals() which may run any code, including flush() on the same file...

In Modules/_io/buffereredio.c, the two callers to PyErr_CheckSignals() should ensure that 'self' is in a stable state, and release the lock while they run PyErr_CheckSignals().


#0  sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
#1  0x000000000049ac7d in PyThread_acquire_lock_timed (lock=0x21e24d0,
    microseconds=-1) at Python/thread_pthread.h:338
#2  0x00000000004c6486 in bufferedwriter_write (self=0x7f02b649d730,
    args=<value optimized out>) at ./Modules/_io/bufferedio.c:1751
#3  0x00000000004d8e29 in PyObject_Call (func=
    <built-in method write of _io.BufferedWriter object at remote 0x7f02b649d730>, arg=<unknown at remote 0x80>, kw=<value optimized out>)
    at Objects/abstract.c:2149
#4  0x00000000004db093 in PyObject_CallMethodObjArgs (callable=
    <built-in method write of _io.BufferedWriter object at remote 0x7f02b649d730>, name=<value optimized out>) at Objects/abstract.c:2350
#5  0x00000000004c9870 in _textiowrapper_writeflush (self=0x7f02b64a9530)
    at ./Modules/_io/textio.c:1237
#6  0x00000000004ca3be in textiowrapper_write (self=0x7f02b64a9530,
    args=<value optimized out>) at ./Modules/_io/textio.c:1318
#7  0x00000000004d81b7 in PyObject_Call (func=
    <built-in method write of _io.TextIOWrapper object at remote 0x7f02b64a9530>, arg=<unknown at remote 0x80>, kw=0x0) at Objects/abstract.c:2149
#8  0x000000000045e843 in PyEval_CallObjectWithKeywords (func=
    <built-in method write of _io.TextIOWrapper object at remote 0x7f02b64a9530>, arg=('\n',), kw=0x0) at Python/ceval.c:3754
#9  0x00000000004fb696 in PyFile_WriteObject (v=<value optimized out>,
    f=<value optimized out>, flags=<value optimized out>)
    at Objects/fileobject.c:156
#10 0x00000000004fb860 in PyFile_WriteString (s=<value optimized out>, f=
    <_io.TextIOWrapper at remote 0x7f02b64a9530>) at Objects/fileobject.c:181
#11 0x000000000045c49b in builtin_print (self=<value optimized out>, args=
    ('got sigint',), kwds=<value optimized out>) at Python/bltinmodule.c:1510
#12 0x0000000000465ded in call_function (f=
    Frame 0x22f28b0, for file <stdin>, line 1, in sighandler (arg1=2, arg2=Frame 0x22de7f0, for file <stdin>, line 2, in <module> ()),
    throwflag=<value optimized out>) at Python/ceval.c:3874
#13 PyEval_EvalFrameEx (f=
    Frame 0x22f28b0, for file <stdin>, line 1, in sighandler (arg1=2, arg2=Frame 0x22de7f0, for file <stdin>, line 2, in <module> ()),
    throwflag=<value optimized out>) at Python/ceval.c:2673
#14 0x0000000000466ee5 in PyEval_EvalCodeEx (co=0x7f02b5770cf0,
    globals=<value optimized out>, locals=<value optimized out>, args=0x2,
    argcount=<value optimized out>, kws=<value optimized out>, kwcount=0,
    defs=0x0, defcount=0, kwdefs=0x0, closure=0x0) at Python/ceval.c:3310
#15 0x00000000005027f4 in function_call (func=
    <function at remote 0x7f02b52e71e8>, arg=
    (2, Frame 0x22de7f0, for file <stdin>, line 2, in <module> ()), kw=0x0)
    at Objects/funcobject.c:630
#16 0x00000000004d81b7 in PyObject_Call (func=
    <function at remote 0x7f02b52e71e8>, arg=<unknown at remote 0x80>, kw=0x0)
    at Objects/abstract.c:2149
#17 0x000000000045e843 in PyEval_CallObjectWithKeywords (func=
    <function at remote 0x7f02b52e71e8>, arg=
    (2, Frame 0x22de7f0, for file <stdin>, line 2, in <module> ()), kw=0x0)
    at Python/ceval.c:3754
#18 0x00000000004a04cf in PyErr_CheckSignals ()
    at ./Modules/signalmodule.c:929
#19 0x00000000004c56cd in _bufferedwriter_flush_unlocked (self=
    0x7f02b649d730, restore_pos=0) at ./Modules/_io/bufferedio.c:1709
#20 0x00000000004c5b3e in buffered_flush (self=0x7f02b649d730,
    args=<value optimized out>) at ./Modules/_io/bufferedio.c:709
History
Date User Action Args
2010-11-21 09:25:36amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, isandler, pitrou
2010-11-21 09:25:36amaury.forgeotdarcsetmessageid: <1290331536.35.0.544665734609.issue10478@psf.upfronthosting.co.za>
2010-11-21 09:25:34amaury.forgeotdarclinkissue10478 messages
2010-11-21 09:25:34amaury.forgeotdarccreate