Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328535 - Adding a breakpoint may cause a deadlock
Summary: Adding a breakpoint may cause a deadlock
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: Debug (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.3 M3   Edit
Assignee: Michael Rennie CLA
QA Contact: Simon Kaegi CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-23 16:05 EDT by Peter Rybin CLA
Modified: 2010-10-25 11:00 EDT (History)
2 users (show)

See Also:


Attachments
fix (1.16 KB, patch)
2010-10-25 11:00 EDT, Michael Rennie CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Rybin CLA 2010-10-23 16:05:53 EDT
Build Identifier: 20100618-0524

I guess you shouldn't touch Maker from a breakpoint listener (touch should become asynchronous).

Here are stacktraces of 2 threads (see annotated frames):

Deadlock with Worker-1 and Worker-3

locks:
1. Java monitor of JavaScriptDebugTarget instance
2. WorkManager lock


Thread [Worker-1] (Suspended)    
    Object.wait(long) line: not available [native method]    
    Semaphore.acquire(long) line: 39    
    OrderedLock.doAcquire(Semaphore, long) line: 176    
    OrderedLock.acquire(long) line: 110    
-> waiting ->    OrderedLock.acquire() line: 84    
    WorkManager.checkIn(ISchedulingRule, IProgressMonitor) line: 118    
    Workspace.prepareOperation(ISchedulingRule, IProgressMonitor) line: 1914    
    Marker.setAttribute(String, Object) line: 233    
    Marker.setAttribute(String, int) line: 222    
    JavaScriptLineBreakpoint(JavaScriptBreakpoint).incrementInstallCount() line: 299    
    JavaScriptLineBreakpoint(JavaScriptBreakpoint).registerRequest(JavaScriptDebugTarget, EventRequest) line: 360    
    JavaScriptLineBreakpoint.createRequest(JavaScriptDebugTarget, ScriptReference) line: 99    
    JavaScriptLineBreakpoint(JavaScriptBreakpoint).addToTarget(JavaScriptDebugTarget) line: 160    
-> taking lock ->    JavaScriptDebugTarget.breakpointAdded(IBreakpoint) line: 791    
    JavaScriptDebugTarget.initializeBreakpoints() line: 382    
    JavaScriptDebugTarget.initialize() line: 126    
    JavaScriptDebugTarget.<init>(VirtualMachine, IProcess, ILaunch, boolean, boolean) line: 116    
    RemoteJavaScriptLaunchDelegate.launch(ILaunchConfiguration, String, ILaunch, IProgressMonitor) line: 102    
    LaunchConfiguration.launch(String, IProgressMonitor, boolean, boolean) line: 853    
    LaunchConfiguration.launch(String, IProgressMonitor, boolean) line: 702    
    DebugUIPlugin.buildAndLaunch(ILaunchConfiguration, String, IProgressMonitor) line: 923    
    DebugUIPlugin$8.run(IProgressMonitor) line: 1126    
    Worker.run() line: 54    
Thread [Worker-2] (Suspended)    
Thread [Worker-3] (Stepping)    
-> waiting ->        JavaScriptDebugTarget.breakpointChanged(IBreakpoint, IMarkerDelta) line: 807    
    BreakpointManager$BreakpointNotifier.run() line: 926    
    SafeRunner.run(ISafeRunnable) line: 42    
    BreakpointManager$BreakpointNotifier.notify(IBreakpoint[], IMarkerDelta[], int) line: 946    
    BreakpointManager.fireUpdate(List, List, int) line: 860    
    BreakpointManager.access$3(BreakpointManager, List, List, int) line: 850    
    BreakpointManager$BreakpointManagerVisitor.update() line: 719    
    BreakpointManager.resourceChanged(IResourceChangeEvent) line: 655    
    NotificationManager$2.run() line: 291    
    SafeRunner.run(ISafeRunnable) line: 42    
-> taking lock ->        NotificationManager.notify(ResourceChangeListenerList$ListenerEntry[], IResourceChangeEvent, boolean) line: 285    
    NotificationManager.broadcastChanges(ElementTree, ResourceChangeEvent, boolean) line: 149    
    Workspace.broadcastBuildEvent(Object, int, int) line: 311    
    AutoBuildJob.doBuild(IProgressMonitor) line: 147    
    AutoBuildJob.run(IProgressMonitor) line: 242    
    Worker.run() line: 54    



Reproducible: Sometimes

Steps to Reproduce:
Exact reproduce steps are lost unfortunately.
There might have been some non-trivial Eclipse configuration.
All starts with adding a breakpoint.
However the stacktraces in "Details" should explain.
Comment 1 Michael Rennie CLA 2010-10-25 11:00:23 EDT
Created attachment 181646 [details]
fix

Good catch Peter!

You are correct in your assessment, we should be using the async API from Breakpoint to be setting attributes. The patch corrects this for incrementInstallCount and decrementInstallCount.
Comment 2 Michael Rennie CLA 2010-10-25 11:00:53 EDT
applied patch to HEAD