Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318970

Summary: 100% CPU after saving a large file with syntax error
Product: z_Archived Reporter: Seva Lapsha <seva.lapsha>
Component: PDTAssignee: PHP UI <php.ui-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: major    
Priority: P2 CC: ganoro, heiko.boettger, silviya, wywrzal
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Seva Lapsha CLA 2010-07-06 04:38:10 EDT
I have a class like this:

class Some_Class {
function some_method() {}
function edited_method($something) {
if($something) { // <-- if is not closed
}
function other_method() {}
}

In fact the class is much larger. When saving the class, lots of errors occure and take 100% CPU for 2 minutes. THe errors all the same are:

java.lang.NullPointerException
	at org.eclipse.php.internal.core.typeinference.PHPModelUtils.getMethodFields(PHPModelUtils.java:657)
	at org.eclipse.php.internal.core.codeassist.PHPSelectionEngine.getGlobalOrMethodFields(PHPSelectionEngine.java:765)
	at org.eclipse.php.internal.core.codeassist.PHPSelectionEngine.internalResolve(PHPSelectionEngine.java:555)
	at org.eclipse.php.internal.core.codeassist.PHPSelectionEngine.select(PHPSelectionEngine.java:144)
	at org.eclipse.dltk.internal.core.Openable.codeSelect(Openable.java:553)
	at org.eclipse.dltk.internal.core.AbstractSourceModule.codeSelect(AbstractSourceModule.java:85)
	at org.eclipse.dltk.internal.core.AbstractSourceModule.codeSelect(AbstractSourceModule.java:76)
	at org.eclipse.php.internal.ui.editor.highlighters.InternalClassHighlighting.isInternalClass(InternalClassHighlighting.java:60)
	at org.eclipse.php.internal.ui.editor.highlighters.InternalClassHighlighting.access$0(InternalClassHighlighting.java:57)
	at org.eclipse.php.internal.ui.editor.highlighters.InternalClassHighlighting$InternalClassApply.visit(InternalClassHighlighting.java:29)
	at org.eclipse.php.internal.core.ast.nodes.Identifier.accept0(Identifier.java:66)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.FunctionName.childrenAccept(FunctionName.java:74)
	at org.eclipse.php.internal.core.ast.nodes.FunctionName.accept0(FunctionName.java:68)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.FunctionInvocation.childrenAccept(FunctionInvocation.java:86)
	at org.eclipse.php.internal.core.ast.nodes.FunctionInvocation.accept0(FunctionInvocation.java:80)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.StaticMethodInvocation.childrenAccept(StaticMethodInvocation.java:82)
	at org.eclipse.php.internal.core.ast.nodes.StaticMethodInvocation.accept0(StaticMethodInvocation.java:75)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.Assignment.childrenAccept(Assignment.java:130)
	at org.eclipse.php.internal.core.ast.nodes.Assignment.accept0(Assignment.java:159)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.ExpressionStatement.childrenAccept(ExpressionStatement.java:73)
	at org.eclipse.php.internal.core.ast.nodes.ExpressionStatement.accept0(ExpressionStatement.java:67)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.Block.childrenAccept(Block.java:97)
	at org.eclipse.php.internal.core.ast.nodes.Block.accept0(Block.java:90)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.FunctionDeclaration.childrenAccept(FunctionDeclaration.java:108)
	at org.eclipse.php.internal.core.ast.nodes.FunctionDeclaration.accept0(FunctionDeclaration.java:97)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.MethodDeclaration.childrenAccept(MethodDeclaration.java:90)
	at org.eclipse.php.internal.core.ast.nodes.MethodDeclaration.accept0(MethodDeclaration.java:82)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.Block.childrenAccept(Block.java:97)
	at org.eclipse.php.internal.core.ast.nodes.Block.accept0(Block.java:90)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.ClassDeclaration.childrenAccept(ClassDeclaration.java:118)
	at org.eclipse.php.internal.core.ast.nodes.ClassDeclaration.accept0(ClassDeclaration.java:104)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.core.ast.nodes.Program.childrenAccept(Program.java:191)
	at org.eclipse.php.internal.core.ast.nodes.Program.accept0(Program.java:184)
	at org.eclipse.php.internal.core.ast.nodes.ASTNode.accept(ASTNode.java:275)
	at org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticHighlighting.consumes(AbstractSemanticHighlighting.java:93)
	at org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticHighlighting.consumes(AbstractSemanticHighlighting.java:102)
	at org.eclipse.wst.sse.ui.internal.style.SemanticHighlightingReconciler.reconcile(SemanticHighlightingReconciler.java:116)
	at org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor.endProcessing(DocumentRegionProcessor.java:85)
	at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor.run(DirtyRegionProcessor.java:655)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 1 Zhongwei Zhao CLA 2010-07-09 00:35:10 EDT
Hi

Can you attach the whole file,thanks!
Comment 2 Seva Lapsha CLA 2010-07-09 04:09:27 EDT
No, this is a proprietary code.
Comment 3 Roy Ganor CLA 2010-07-09 04:17:53 EDT
(In reply to comment #2)
> No, this is a proprietary code.

ok, so it seems like one of the highlighters crashes. The "internal classes" coloring. So for now you can turn it off.

Zhao, did you turned on this rule and used Seva's simple example?
Comment 4 Seva Lapsha CLA 2010-07-09 08:02:36 EDT
(In reply to comment #3)
> (In reply to comment #2)
> > No, this is a proprietary code.
> 
> ok, so it seems like one of the highlighters crashes. The "internal classes"
> coloring. So for now you can turn it off.
> 
> Zhao, did you turned on this rule and used Seva's simple example?

BTW, most of the problems I have disappear if I disable the non-default highlighters. Seems they are not tested good enough.
Comment 5 Zhongwei Zhao CLA 2010-07-09 08:23:00 EDT
OK,I will try again,but I have tested highlighters more(may be still not enough) for another bug.
Comment 6 Zhongwei Zhao CLA 2010-07-09 20:54:37 EDT
Hi Seva

I used
class Some_Class {
function some_method() {}
function edited_method($something) {
if($something) { // <? if is not closed
}
function other_method() {}
}

to test,if there is no closed "}",the highlighters does not work,but I could not reproduce your bug when I save the file.My test file has 350 lines.
Comment 7 Seva Lapsha CLA 2010-07-10 00:38:59 EDT
The classes I work on have lots (700-2000) of lines of non trivial code - loops, conditions, switches, array access, object method invocations, variable assignments.

BTW, I'm not sure, which files are you using while testing, but my advice is to start full testing of the popular frameworks & applications source code - ZF, PEAR, Wordpress, phpBB, Drupal, Joomla, etc.
Comment 8 Seva Lapsha CLA 2010-07-10 00:40:54 EDT
And I have all the possible highlighters enabled and all the semantic analysis options on warning or higher, if it can be relevant.
Comment 9 Zhongwei Zhao CLA 2010-07-10 22:30:19 EDT
I used ZF to test long time ago,btw which pdt version do you use?
Comment 10 Seva Lapsha CLA 2010-07-11 04:34:34 EDT
2.2.0
Comment 11 Roy Ganor CLA 2010-08-04 05:58:30 EDT
After consulting with QA, we need to continue the deep performance auditing to complete the fixes for these issues.

Also we need others to help us out with reproduction, obviously there are performance bugs that can't be simulated very easily.
Comment 12 Michal Niewrzal CLA 2015-06-02 16:12:54 EDT
Quite old issue. Cannot reproduce.
Comment 13 Sylvia Tancheva CLA 2015-06-11 08:44:12 EDT
Seva, I'm closing this. We've done a lot of performance improvements in the past years. I hope you do not have this issue anymore, but if it eventually appears again please help on reproducing.