Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Deadlock on launch due to CBreakpointManager

Before I go creating a new bug report I was hoping to get some opinions on the following deadlock. I'm not running HEAD so I can't guarantee it'll occur for everybody, but the code (HEAD) seems to still suffer.
To reproduce try:

- clear workspace
- new managed make project with autobuild
- create a new file in project, add code and save
- add breakpoint
- create launch with stop on main
- run launch

Thread 1:

AutoBuildJob (owns workspace job queue) -> ... -> BreakpointManager.resourceChanged(...) -> CBreakpointManager.breakpointsChanged(...)

public void breakpointsChanged( IBreakpoint[] breakpoints, IMarkerDelta[] deltas ) {
		ArrayList removeList = new ArrayList( breakpoints.length );
		ArrayList installList = new ArrayList( breakpoints.length );
synchronized ( getBreakpointMap() ) { ###### Waiting for map to become free ####


Thread 2:

EventManager -> CBreakpointManager.handleDebugEvents(...) -> handleBreakpointCreatedEvent(...) -> doHandleLocationBreakpointCreatedEvent(...)

private void doHandleLocationBreakpointCreatedEvent ( ICDILocationBreakpoint cdiBreakpoint ) {
		if ( cdiBreakpoint.isTemporary() )
			return;
		ICBreakpoint breakpoint = null;
synchronized( getBreakpointMap() ) { ####### Has lock on map #######
			breakpoint = getBreakpointMap().getCBreakpoint( cdiBreakpoint );
			if ( breakpoint == null ) {
breakpoint = createLocationBreakpoint( cdiBreakpoint ); ####### Requires job to execute on workspace job queue #####
			}
			if ( breakpoint != null )
				getBreakpointMap().put( breakpoint, cdiBreakpoint );
		}

public CBreakpoint( final IResource resource, final String markerType, final Map attributes, final boolean add ) throws CoreException {
		this();
		IWorkspaceRunnable wr = new IWorkspaceRunnable() {

			public void run( IProgressMonitor monitor ) throws CoreException {
				// create the marker
				setMarker( resource.createMarker( markerType ) );
				// set attributes
				ensureMarker().setAttributes( attributes );
				//set the marker message
				setAttribute( IMarker.MESSAGE, getMarkerMessage() );
				// add to breakpoint manager if requested
				register( add );
			}
		};
run( wr ); ##### Cannot execute due to AutoBuildJob waiting to complete ##########
	}



I'm not sure if having a job queued inside the synchronise is a good idea, for this exact reason. Any comments are much appreciated.

Ryan Hapgood,
HI-TECH Software



Back to the top