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: PyThread_release_lock with pthreads munges errno
Type: behavior Stage: test needed
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, dugan, jpe, sdeibel
Priority: normal Keywords: patch

Created on 2006-12-05 03:08 by sdeibel, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
errno-fix.diff sdeibel, 2009-04-01 17:54 Patch against Python 2.6.1
testcase.tgz sdeibel, 2009-04-01 23:17 Failed test case -- in case this is reopened
Messages (6)
msg61045 - (view) Author: Stephan R.A. Deibel (sdeibel) Date: 2006-12-05 03:08
In normal operation with pthreads when PyThread_release_lock is called and it calls PyThread_acquire_lock in the "sanity check" errno will be set to 11 and left that way.  It seems like this should not happen so thread switches don't arbitrarily and w/o much reason alter the program state.

I ran into this working on a threaded debugger where a lock is used internally.  The debugger I'm writing now saves/restores errno in its tracer but it seems like there is potential for this bug all over the place.
msg84593 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-03-30 17:39
Stephan,
Can you provide a test case?
msg84812 - (view) Author: Stephan R.A. Deibel (sdeibel) Date: 2009-03-31 15:53
If you are at PyCon 2009 sprints, try to see if you can find John
Ehresman in the Python Core sprint to see it happen at line 115 of
threadops.c in the Wing 3.2 source base.  If you're not there or can't
find him, I'll try to make a small example later.  Feel free to email me
directly also at sdeibel at wingware dot com. Note I saw this w/
pthreads and it may be that it does not occur under other threading
implementations.
msg85060 - (view) Author: Stephan R.A. Deibel (sdeibel) Date: 2009-04-01 17:54
Here is a patch against Python 2.6.1 that restores errno after the
"sanity check" in lock_PyThread_release_lock in Modules/threadmodule.c.

A potential controversy is whether it should be done here or in
thread_pthread.h but I believe that we should protect errno from
spurious change by _any_ threading model that objects to this internal 
attempt to acquire an already acquired lock.
msg85067 - (view) Author: John Ehresman (jpe) * Date: 2009-04-01 18:36
Any possibility of a test case?
msg85117 - (view) Author: Stephan R.A. Deibel (sdeibel) Date: 2009-04-01 23:17
He he, well my attempts at replicating this on Linux and OS X failed
using Python 2.3->2.6 so I'm closing this bug.  I'm uploading the test
case for what it's worth.  My best guess at what happened is that there
was some interaction w/ older gdb, since I do know that I stepped
through code in gdb to see this happen, or perhaps it was on older
pthreads.  The bug report dates from what I believe I had another
desktop computer and older Linux version on that.  Thanks for spurring
me on to looking at this again and in more detail.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44305
2009-04-01 23:21:34benjamin.petersonsetresolution: not a bug
2009-04-01 23:17:28sdeibelsetstatus: open -> closed
files: + testcase.tgz
messages: + msg85117
2009-04-01 18:36:02jpesetnosy: + jpe
messages: + msg85067
2009-04-01 17:54:45sdeibelsetfiles: + errno-fix.diff
keywords: + patch
messages: + msg85060
2009-03-31 21:22:44dugansetnosy: + dugan
2009-03-31 15:53:13sdeibelsetmessages: + msg84812
2009-03-30 17:39:25ajaksu2setversions: + Python 2.6, - Python 2.5
nosy: + ajaksu2

messages: + msg84593

type: behavior
stage: test needed
2006-12-05 03:08:22sdeibelcreate