Re: Thread-unsafe access to lock->owner in PR_Lock
Wan-Teh Chang <[email protected]> Fri, 20 Dec 2013 12:51:10 -0800
| Newsgroups | gmane.comp.mozilla.devel.nspr |
|---|---|
| Message-ID | <CALTJjxFFDGi7ZG+auJFKXGdEq1ZaHAncDOruPgSffx+x3xpmGQ@mail.gmail.com> |
On Thu, Dec 19, 2013 at 3:47 PM, Wan-Teh Chang <[email protected]> wrote: > > Hi Alexander, > > PRLock is a non-recursive lock. So the PR_ASSERT(lock->owner != me) on > line 200 is trying to detect an attempt to lock a PRLock recursively. > It is intended as a debugging aid for NSPR users. > > This debugging aid is useful, so ideally we should find a way to do it > the right way. > > If we swap lines 200 and 201, it will only work for a _PR_MD_LOCK > implementation that allows a lock to be acquired recursively. As Dave > Hylands pointed out, in a _PR_MD_LOCK implementation that deadlocks, > we won't be able to see the assertion failure. However, since we only > use the PR_Lock code in prulock.c on Windows, where _PR_MD_LOCK > (EnterCriticalSection) is recursive, we can make the change you > suggested. I filed an NSPR bug report and wrote a patch: https://bugzilla.mozilla.org/show_bug.cgi?id=952621 Wan-Teh Chang