This is the mail archive of the java-prs@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

libgcj/171: wait/notify doesn't work if monitor is locked recursivly



>Number:         171
>Category:       libgcj
>Synopsis:       wait/notify doesn't work if monitor is locked recursivly
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    tromey
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 10 23:40:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Bryce McKinlay
>Release:        unknown-1.0
>Organization:
>Environment:
RedHat 6.1 w/ glibc 2.1.3
>Description:
We use recursive mutexes on pthreads implementations that 
support them. On linux, at least, pthread_cond_wait()
just calls pthread_mutex_unlock(), which of course doesn't 
"fully" unlock a recursive mutex - only decrements its 
lock count! 

This means that ownership of the monitor is not 
relinquished on wait(), resulting in a deadlock if the 
thread has aquired the monitor more than once. 

>How-To-Repeat:
Run the attached test case.
>Fix:
Never use native recursive mutexes, instead implementing
the recursion ourselves. This would clean up the code in
posix_threads.h considerably, fix the Solaris 7 bug (PR 110), 
and IMO would have a negligable impact on performance. 
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="RecursiveLock.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="RecursiveLock.java"

cHVibGljIGNsYXNzIFJlY3Vyc2l2ZUxvY2sgZXh0ZW5kcyBUaHJlYWQKewogIHB1YmxpYyBzdGF0
aWMgdm9pZCBtYWluKFN0cmluZyBhcmdzW10pIHRocm93cyBJbnRlcnJ1cHRlZEV4Y2VwdGlvbgog
IHsKICAgIFJlY3Vyc2l2ZUxvY2sgcmwgPSBuZXcgUmVjdXJzaXZlTG9jaygpOwogICAgcmwuc3Rh
cnQoKTsKICAgIC8vIEdpdmUgdGhlIGNoaWxkIHRocmVhZCB0aW1lIHRvIHN0YXJ0IHVwLgogICAg
VGhyZWFkLnNsZWVwKDEwMDApOwogICAgc3luY2hyb25pemVkIChybCkKICAgIHsKICAgICAgcmwu
bm90aWZ5KCk7CiAgICB9CiAgfQogIAogIHB1YmxpYyBzeW5jaHJvbml6ZWQgdm9pZCBydW4oKQog
IHsKICAgIC8vIE5vdGU6IHR3byBsZXZlbHMgb2Ygc3luY2hyb25pemF0aW9uLi4uCiAgICBzeW5j
aHJvbml6ZWQgKHRoaXMpCiAgICB7CiAgICAgIHRyeQogICAgICB7CglTeXN0ZW0ub3V0LnByaW50
bG4oIndhaXQoKS4uLiIpOwoJd2FpdCgpOwoJU3lzdGVtLm91dC5wcmludGxuKCJvayIpOwogICAg
ICB9CiAgICAgIGNhdGNoIChJbnRlcnJ1cHRlZEV4Y2VwdGlvbiB4KQogICAgICB7CglTeXN0ZW0u
b3V0LnByaW50bG4oeCk7CiAgICAgIH0KICAgIH0KICB9ICAKfQo=

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]