fix cond_race... was RE: src/winsup/cygwin ChangeLog thread.cc thread.h ...

Norman Vine nhv@cape.com
Sun Sep 30 05:21:00 GMT 2001


 Robert Collins writes:
>
>----- Original Message -----
>From: "Norman Vine"
>
>> Robert Collins writes:
>>
>> >----- Original Message -----
>> >From: "Jason Tishler" <jason@tishler.net>
>> >>
>> >> On Fri, Sep 28, 2001 at 05:48:16PM +1000, Robert Collins wrote:
>> >> > Well this patch should make evreything good -  fixing the critical
>> >> > section induced race.
>> >>
>> >> At the risk of appearing dense...  Should this patch fix the pthreads
hang
>> >> trigger by Python's test_threadedtempfile regression test?
>> >
>> >I've checked in my completed code. I -cannot- tickle this bug via my
>> >test suite at all now. (I found that one of my test scripts was slightly
>> >buggy in that it made an incorrect assumption - it was passing when this
>> >bug was tickled - correcting that let me hit this bug nearly every time
>> >:]).
>> >
>> >So please, give it a go and see how it fares.
>>
>> This now causes a hard crash in any of the Python threading tests
>> with an attempt to read memory at 0x00000018 failure.
>>
>> Note I believe this started, for me at least, with the
>second piece of this  patch.
>> Also note that I could not tickle this bug before.
>
>Interesting. Well I can drop you an updated test case which I'm sure
>will tickle the older .dll. Also I found that backgrounding the window
>the test is running in took the chance of hitting the bug from "very
>likely" to "sure thing" - if you'll excuse the technical talk :].
>
>> Win2k sp2  Cygwin=ntsec   python src 2-1.1-2 from cygwin distribution
>>

See attached

-------------- next part --------------
D:\usr\src\python-2.1.1>d:/bin/gdb.exe -nw /usr/src/python-2.1.1/python.exe 1004

GNU gdb 5.0 (20010428-1)
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 "i686-pc-cygwin"...
/usr/src/python-2.1.1/1004: No such file or directory.
Attaching to program `/usr/src/python-2.1.1/python.exe', process 1004

Program received signal SIGSEGV, Segmentation fault.

Program received signal SIGSEGV, Segmentation fault.

Program received signal SIGSEGV, Segmentation fault.

Program received signal SIGSEGV, Segmentation fault.

Program received signal SIGSEGV, Segmentation fault.

Program received signal SIGSEGV, Segmentation fault.

Program received signal SIGSEGV, Segmentation fault.

Program received signal SIGSEGV, Segmentation fault.

---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) bt
#0  0x77f821e1 in _libkernel32_a_iname ()
#1  0x61062e0c in pthread_mutex::Lock (this=0x0)
    at /src/cygwin/src/winsup/cygwin/thread.cc:694
#2  0x6106452a in __pthread_cond_dowait (cond=0xa05e6fc, mutex=0xa05e700,
    waitlength=-1) at /src/cygwin/src/winsup/cygwin/thread.cc:1776
#3  0x61064640 in pthread_cond_wait (cond=0xa05e6fc, mutex=0xa05e700)
    at /src/cygwin/src/winsup/cygwin/thread.cc:1806
#4  0x61d928a5 in PyThread_acquire_lock (lock=0xa05e6f8, waitflag=1)
    at Python/thread_pthread.h:313
#5  0x61d721f6 in eval_code2 (co=0xa07ac48, globals=0xa088aa4, locals=0x0,
    args=0xa0b86cc, argcount=0, kws=0xa0b86cc, kwcount=0, defs=0xa0505e8,
    defcount=1, closure=0x0) at Python/ceval.c:721
#6  0x61d76405 in fast_function (func=0xa0800e4, pp_stack=0x22f8fc, n=0, na=0,
    nk=0) at Python/ceval.c:3022
#7  0x61d7485d in eval_code2 (co=0xa07b2e0, globals=0xa088aa4, locals=0x0,
    args=0xa0b63f0, argcount=1, kws=0x0, kwcount=0, defs=0xa080330,
    defcount=6, closure=0x0) at Python/ceval.c:1972
#8  0x61d76303 in call_eval_code2 (func=0xa0802ec, arg=0xa0b63e4, kw=0x0)
    at Python/ceval.c:2966
#9  0x61d75e42 in call_object (func=0xa0802ec, arg=0xa0b63e4, kw=0x0)
    at Python/ceval.c:2805
#10 0x61d761b9 in call_method (func=0xa0802ec, arg=0xa0150f4, kw=0x0)
    at Python/ceval.c:2923
#11 0x61d75e2e in call_object (func=0xa0b790c, arg=0xa0150f4, kw=0x0)
---Type <return> to continue, or q <return> to quit---
    at Python/ceval.c:2803
#12 0x61d75c8e in PyEval_CallObjectWithKeywords (func=0xa0b790c,
    arg=0xa0150f4, kw=0x0) at Python/ceval.c:2740
#13 0x61d48636 in PyInstance_New (klass=0xa09fadc, arg=0xa0150f4, kw=0x0)
    at Objects/classobject.c:489
#14 0x61d75e6a in call_object (func=0xa09fadc, arg=0xa0150f4, kw=0x0)
    at Python/ceval.c:2809
#15 0x61d766f0 in do_call (func=0xa09fadc, pp_stack=0x22fb8c, na=0, nk=0)
    at Python/ceval.c:3123
#16 0x61d74877 in eval_code2 (co=0xa086468, globals=0xa01544c, locals=0x0,
    args=0xa020f84, argcount=0, kws=0xa020f84, kwcount=0, defs=0x0,
    defcount=0, closure=0x0) at Python/ceval.c:1975
#17 0x61d76405 in fast_function (func=0xa09f45c, pp_stack=0x22fcbc, n=0, na=0,
    nk=0) at Python/ceval.c:3022
#18 0x61d7485d in eval_code2 (co=0xa07d258, globals=0xa01544c,
    locals=0xa01544c, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
    defcount=0, closure=0x0) at Python/ceval.c:1972
#19 0x61d71480 in PyEval_EvalCode (co=0xa07d258, globals=0xa01544c,
    locals=0xa01544c) at Python/ceval.c:341
#20 0x61d8f639 in run_node (n=0xa05c868,
    filename=0x614d5164 "Lib/test/test_threadedtempfile.py",
    globals=0xa01544c, locals=0xa01544c, flags=0x22fe70)
    at Python/pythonrun.c:1045
#21 0x61d8f5ea in run_err_node (n=0xa05c868,
---Type <return> to continue, or q <return> to quit---
    filename=0x614d5164 "Lib/test/test_threadedtempfile.py",
    globals=0xa01544c, locals=0xa01544c, flags=0x22fe70)
    at Python/pythonrun.c:1032
#22 0x61d8f5ba in PyRun_FileExFlags (fp=0xa010374,
    filename=0x614d5164 "Lib/test/test_threadedtempfile.py", start=257,
    globals=0xa01544c, locals=0xa01544c, closeit=1, flags=0x22fe70)
    at Python/pythonrun.c:1023
#23 0x61d8e864 in PyRun_SimpleFileExFlags (fp=0xa010374,
    filename=0x614d5164 "Lib/test/test_threadedtempfile.py", closeit=1,
    flags=0x22fe70) at Python/pythonrun.c:665
#24 0x61d8e30c in PyRun_AnyFileExFlags (fp=0xa010374,
    filename=0x614d5164 "Lib/test/test_threadedtempfile.py", closeit=1,
    flags=0x22fe70) at Python/pythonrun.c:479
#25 0x61d94a68 in Py_Main (argc=2, argv=0x614d50f4) at Modules/main.c:320
#26 0x00401061 in main (argc=2, argv=0x614d50f4) at Modules/python.c:10
#27 0x61003f42 in dll_crt0_1 () at /src/cygwin/src/winsup/cygwin/dcrt0.cc:772
#28 0x61004171 in _dll_crt0 () at /src/cygwin/src/winsup/cygwin/dcrt0.cc:840
#29 0x610041b0 in dll_crt0 (uptr=0x0)
    at /src/cygwin/src/winsup/cygwin/dcrt0.cc:852
#30 0x004010bf in cygwin_crt0 ()
    at /src/cygwin/src/winsup/cygwin/lib/cygwin_crt0.c:33
(gdb) select 1
Current language:  auto; currently c++
(gdb) info locals
this = (pthread_mutex *) 0x4
(gdb) up
#2  0x6106452a in __pthread_cond_dowait (cond=0xa05e6fc, mutex=0xa05e700,
    waitlength=-1) at /src/cygwin/src/winsup/cygwin/thread.cc:1776
1776      (*cond)->mutex->Lock ();
(gdb) info locals
cond = (pthread_cond_t *) 0xa05e6fc
mutex = (pthread_mutex_t *) 0xa05e700
waitlength = 4
rv = 0
(gdb) up
#3  0x61064640 in pthread_cond_wait (cond=0xa05e6fc, mutex=0xa05e700)
    at /src/cygwin/src/winsup/cygwin/thread.cc:1806
1806      return __pthread_cond_dowait (cond, mutex, INFINITE);
(gdb) info locals
cond = (pthread_cond_t *) 0x4
mutex = (pthread_mutex_t *) 0x4
(gdb) up
#4  0x61d928a5 in PyThread_acquire_lock (lock=0xa05e6f8, waitflag=1)
    at Python/thread_pthread.h:313
313                             status = pthread_cond_wait(&thelock->lock_releas
ed,
Current language:  auto; currently c
(gdb) info locals
lock = 0xa05e6f8
success = 168158976
status = 4
error = 0
(gdb) up
#5  0x61d721f6 in eval_code2 (co=0xa07ac48, globals=0xa088aa4, locals=0x0,
    args=0xa0b86cc, argcount=0, kws=0xa0b86cc, kwcount=0, defs=0xa0505e8,
    defcount=1, closure=0x0) at Python/ceval.c:721
721                                     PyThread_acquire_lock(interpreter_lock,
1);
(gdb) info locals
globals = (PyObject *) 0x4
locals = (PyObject *) 0x4
args = (PyObject **) 0xa07a358
stack_pointer = (PyObject **) 0xa0b6050
next_instr = (unsigned char *) 0xa07ac0d "t"
opcode = 124
oparg = 0
why = WHY_NOT
err = 0
x = (PyObject *) 0xa07a358
v = (PyObject *) 0xa010588
w = (PyObject *) 0xa07ac20
u = (PyObject *) 0xffffffff
t = (PyObject *) 0xa07a358
stream = (PyObject *) 0x0
f = (PyFrameObject *) 0xa0b5f00
fastlocals = (PyObject **) 0xa0b6048
freevars = (PyObject **) 0xa0b604c
retval = (PyObject *) 0x0
tstate = (PyThreadState *) 0xa010588
first_instr = (unsigned char *) 0xa07abf4 "\1772\001\1773\001\1774\001t"
(gdb) up
#6  0x61d76405 in fast_function (func=0xa0800e4, pp_stack=0x22f8fc, n=0, na=0,
    nk=0) at Python/ceval.c:3022
3022            return eval_code2((PyCodeObject *)co, globals,
(gdb) info locals
func = (PyObject *) 0x4
pp_stack = (PyObject ***) 0x4
na = 4
nk = 0
co = (PyObject *) 0xa07ac48
globals = (PyObject *) 0xa088aa4
argdefs = (PyObject *) 0x4
closure = (PyObject *) 0x4
d = (PyObject **) 0xa0505e8
nd = 2147344384
(gdb) up
#7  0x61d7485d in eval_code2 (co=0xa07b2e0, globals=0xa088aa4, locals=0x0,
    args=0xa0b63f0, argcount=1, kws=0x0, kwcount=0, defs=0xa080330,
    defcount=6, closure=0x0) at Python/ceval.c:1972
1972                                        x = fast_function(func, &stack_point
er,
(gdb) info locals
na = 168331940
nk = 0
n = 0
pfunc = (PyObject **) 0xa0b86c8
func = (PyObject *) 0x0
globals = (PyObject *) 0x4
locals = (PyObject *) 0x4
args = (PyObject **) 0xa088aa4
stack_pointer = (PyObject **) 0xa0b86cc
next_instr = (unsigned char *) 0xa07ae22 "\203\001"
opcode = 131
oparg = 0
why = WHY_NOT
err = 0
x = (PyObject *) 0xa0800e4
v = (PyObject *) 0xa0505e8
w = (PyObject *) 0xa07b128
u = (PyObject *) 0x0
t = (PyObject *) 0xa088aa4
stream = (PyObject *) 0x0
f = (PyFrameObject *) 0xa0b8560
fastlocals = (PyObject **) 0xa0b86a8
freevars = (PyObject **) 0xa0b86c4
retval = (PyObject *) 0x0
---Type <return> to continue, or q <return> to quit---
tstate = (PyThreadState *) 0xa010588
first_instr = (unsigned char *) 0xa07adcc "\177C\001\177E\001t"
(gdb) up
#8  0x61d76303 in call_eval_code2 (func=0xa0802ec, arg=0xa0b63e4, kw=0x0)
    at Python/ceval.c:2966
2966            result = eval_code2(
(gdb) info locals
result = (PyObject *) 0x0
argdefs = (PyObject *) 0x4
d = (PyObject **) 0xa080330
k = (PyObject **) 0x0
nk = 4
nd = 6
(gdb)


More information about the Cygwin-patches mailing list