Skip to content

Hard crash due to bug in JavaParser #56

@xnhp

Description

@xnhp

To reproduce:

  1. Run the DemoApp
  2. In the menu, select "Language > Java"
  3. As the last statement of a method body, enter Set<D and wait a second or so
  4. The application crashes

Stacktrace:

ERROR: Token being duplicated: [TokenImpl: type=8388612; lexeme="}"; line=48; col=4; offs=1211; invalid=false]
java.lang.Exception: Stack trace
	at java.base/java.lang.Thread.dumpStack(Thread.java:1388)
	at org.fife.rsta.ac.java.rjc.lexer.Scanner.pushOntoStack(Scanner.java:105)
	at org.fife.rsta.ac.java.rjc.lexer.Scanner.yyPeek(Scanner.java:706)
	at org.fife.rsta.ac.java.rjc.parser.ASTFactory._getMemberDecl(ASTFactory.java:1084)
	at org.fife.rsta.ac.java.rjc.parser.ASTFactory._getClassBody(ASTFactory.java:405)
	at org.fife.rsta.ac.java.rjc.parser.ASTFactory._getNormalClassDeclaration(ASTFactory.java:1178)
	at org.fife.rsta.ac.java.rjc.parser.ASTFactory._getClassOrInterfaceDeclaration(ASTFactory.java:447)
	at org.fife.rsta.ac.java.rjc.parser.ASTFactory._getTypeDeclaration(ASTFactory.java:1451)
	at org.fife.rsta.ac.java.rjc.parser.ASTFactory.getCompilationUnit(ASTFactory.java:591)
	at org.fife.rsta.ac.java.JavaParser.parse(JavaParser.java:143)
	at org.fife.ui.rsyntaxtextarea.ParserManager.actionPerformed(ParserManager.java:163)
	at java.desktop/javax.swing.Timer.fireActionPerformed(Timer.java:317)
	at java.desktop/javax.swing.Timer$DoPostEvent.run(Timer.java:249)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

This is due to a call to System.exit in a sanity check done in pushOntoStack. JavaParser uses a stack for lookaheads etc. and one of the peek methods (yylex) apparently fails to properly pop a token in some cases, leaving the token on the stack. Then, when re-pushing it, they realise that the token is already on the stack, which shouldn’t happen.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions