• Bug
  • Status: Closed
  • 3 Minor
  • Resolution: Fixed
  • DSO:L1
  • hsingh
  • Reporter: jsala
  • October 16, 2009
  • 0
  • Watchers: 1
  • February 12, 2013
  • November 12, 2009

Attachments

Description

Calling Thread.interrupt() for a DSO-instrumented client thread that is blocked on a wait() call on a shared object does not cause the call to terminate until other clients sharing the same lock get disconnected. Ideally, the wait() call should terminate immediately with an InterruptedException as in non-instrumented Java.

Steps to reproduce:

  • DSO-start the attached program in two client processes. Both processes will start a thread and invoke wait() on a shared object.
  • Wait until “Done!” is displayed in both processes. This indicates that the corresponding threads have been interrupted.
  • The processes don’t exit as one would expect. The corresponding threads are still blocked in the wait() call (see stack dump below) despite they have been interrupted.
  • Kill one of the client processes. The other receives now the InterruptedException and exits cleanly.

The stack dump of both threads when blocked is: Object.wait(long) line: not available [native method] MySharedObject(Object).wait() line: 485 ClientLock.waitForLock(ThreadID, int, Object) line: 676 ClientLock.wait(ThreadID, TimerSpec, Object, WaitListener) line: 396 ClientLockManagerImpl.wait(LockID, ThreadID, TimerSpec, Object, WaitListener) line: 477 StripedClientLockManagerImpl.wait(LockID, ThreadID, TimerSpec, Object, WaitListener) line: 171 ThreadLockManagerImpl.wait(LockID, TimerSpec, Object, WaitListener) line: 58 ClientTransactionManagerImpl.wait(String, TimerSpec, Object) line: 272 ManagerImpl.objectWait(Object) line: 459 ManagerUtil.objectWait(Object) line: 515 MySharedObject.__tc_wrapped_doWait() line: 5 MySharedObject.doWait() line: not available ThreadInterruptTest$1.run() line: 18 Thread.run() line: 619

Surprisingly, the bug does not occur (i.e., the threads exit immediately) if main() is refactored to remove the superfluous use of an ArrayList to hold the (single) Thread object. I have not been able to figure out the reason for this.

Comments

Steve Harris 2009-11-05

How hard is this to fix?

Chris Dennis 2009-11-12

I’ve reproduced this in a system test (and have an associated fix for it) - both of which I will check-in soon. However I’m slightly concerned/confused about the reporters assertion that this worked when he used a straight reference to the thread instead of an ArrayList.

Himadri Singh 2009-12-10

Both clients now throw InterruptedException

Starting Terracotta client… 2009-12-10 11:21:46,609 INFO - Terracotta Enterprise 3.2.0-nightly, as of 20091207-161253 (Revision 5540-14152 by cruise@su10mo4 from 3.2) 2009-12-10 11:21:46,937 INFO - Configuration loaded from the file at ‘c:\Terracotta\terracotta-3.2.0-nightly-ee-rev14152\CDV-1411\tc-config.xml’. 2009-12-10 11:21:47,078 INFO - Log file: ‘c:\Terracotta\terracotta-3.2.0-nightly-ee-rev14152\CDV-1411\clients\tests\ThreadInterruptTest\logs\20091210112147046\terracotta-client.log’. 2009-12-10 11:21:47,281 INFO - Product key found at: C:\Terracotta\terracotta-3.2.0-nightly-ee-rev14152\product.key 2009-12-10 11:21:47,359 INFO - —————- Terracotta product key ————– License type = Trial License number = 1 Licensee = Terracotta Test Product = FX Max clients = 200 Capabilities = roots, sessions, TOC, server striping —————————————————— 2009-12-10 11:21:48,500 INFO - Connection successfully established to server at 10.0.7.27:9510 Waiting for other process… Starting thread… Interrupting thread… Done! java.lang.InterruptedException at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:485) at com.tc.object.locks.LockStateNode$LockWaiter.park(LockStateNode.java:392) at com.tc.object.locks.ClientLockImpl.waitOnLockWaiter(ClientLockImpl.java:237) at com.tc.object.locks.ClientLockImpl.wait(ClientLockImpl.java:200) at com.tc.object.locks.ClientLockImpl.wait(ClientLockImpl.java:165) at com.tc.object.locks.ClientLockManagerImpl.wait(ClientLockManagerImpl.java:508) at com.tc.object.locks.ClientLockManagerImpl.wait(ClientLockManagerImpl.java:203) at com.tc.object.bytecode.ManagerImpl.wait(ManagerImpl.java:806) at com.tc.object.bytecode.ManagerUtil.objectWait(ManagerUtil.java:508) at MySharedObject.__tc_wrapped_doWait(MySharedObject.java:5) at MySharedObject.doWait(MySharedObject.java) at ThreadInterruptTest$1.run(ThreadInterruptTest.java:18) at java.lang.Thread.run(Thread.java:619)