Bug 284153 - Infinite loop -> DeferredUpdateManager -> performValidation <--> addInvalidFigure
Summary: Infinite loop -> DeferredUpdateManager -> performValidation <--> addInvalidFi...
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-21 12:18 EDT by Vitali Yemialyanchyk CLA
Modified: 2010-03-05 05:43 EST (History)
6 users (show)

See Also:


Attachments
stack trace (209.09 KB, image/jpeg)
2009-07-21 12:18 EDT, Vitali Yemialyanchyk CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vitali Yemialyanchyk CLA 2009-07-21 12:18:47 EDT
Created attachment 142152 [details]
stack trace

DeferredUpdateManager -> performValidation()
this cycle has an error:
for (int i = 0; i < invalidFigures.size(); i++) {
 fig = (IFigure) invalidFigures.get(i);
 invalidFigures.set(i, null);
 fig.validate();
}
should be:
for (int i = 0; i < invalidFigures.size(); i++) {
 fig = (IFigure) invalidFigures.get(i);
 fig.validate();
 invalidFigures.set(i, null);
}
cause possible to get infinite loop. I get this loop.
Look -> DeferredUpdateManager -> 
public synchronized void addInvalidFigure(IFigure f) {
	if (invalidFigures.contains(f))
		return;
	queueWork();
	invalidFigures.add(f);
}
Comment 1 Anthony Hunter CLA 2009-07-27 13:04:10 EDT
Do you have an example so we can reproduce the issue?
Comment 2 Vitali Yemialyanchyk CLA 2009-07-28 07:56:36 EDT
you can find code example here:
https://svn.jboss.org/repos/jbosstools/trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/parts -> ShapeEditPart -> getLocation -> commented block. To reproduce - uncomment the block. The infinite loop is after the call -> figureSource.translateToAbsolute(rcSource); If you need more help to reproduce it - ask me.
Anyway I see obvious error in the code and to fix it -> just necessary to change order of calls:
//---
this is wrong order:
invalidFigures.set(i, null);
fig.validate();
//---
this is right order:
fig.validate();
invalidFigures.set(i, null);
//---
Take a look at the stack trace screenshot in attachment:
fig.validate() finally calls function addInvalidFigure.
invalidFigures.set(i, null); -> remove fig from invalidFigures, but
firstly necessary to validate fig and only then 
remove it from invalidFigures.
Comment 3 Mariot Chauvin CLA 2010-02-10 11:43:50 EST
This seems to be a duplicate of Bug 106151 which is closed as invalid.
BTW Vitali I could not access to your example as it ask me a login and password (tried anonymous with empty password without success).