Decompiler sometimes fails to highlight matching braces
See original GitHub issueDescribe the bug In certain situations the decompiler window will fail to highlight braces and will throw an exception, however it only happens when clicking the opening one. I think it has to do with goto labels being placed inside pairs of braces (but not always).
I attach two .asm files, one that triggers the bug after viewing decompilation, and one that doesn’t, which has 3 instructions removed.
I tried to make them as minimal as possible, but I was able to remove only so much lines, removing more makes decompiler realise it can simplify the code further and the broken braces disappear.
To Reproduce Steps to reproduce the behavior:
- Decompile provided example (function
_breaks
) - Go to line 24 and click on the
else
opening bracket, abovelab1
Expected behavior
Java exception window appears with java.util.EmptyStackException
(Clicking on the bottom bracket works, and succesfully highlights the top one)
Screenshots
Attachments Here’s two asm files (plus a basic .c file with weird batch script to build a complete .exe), it might be easier to just run the decompiler on the .asm file directly somehow. example.zip
Here’s a final exe too if that’s acceptable, it has debug information from gcc (function _breaks
at 0x00401511
)
program.zip
Environment (please complete the following information):
- OS: Windows 10
- Java Version: 17.0.2
- Ghidra Version: 10.1.5
- Ghidra Origin: official Github
Additional context Full error log
java.util.EmptyStackException
at java.base/java.util.Stack.peek(Stack.java:101)
at java.base/java.util.Stack.pop(Stack.java:83)
at ghidra.app.decompiler.component.DecompilerUtils.getMatchingBrace(DecompilerUtils.java:592)
at ghidra.app.decompiler.component.ClangHighlightController.highlightBrace(ClangHighlightController.java:377)
at ghidra.app.decompiler.component.ClangHighlightController.addHighlightBrace(ClangHighlightController.java:370)
at ghidra.app.decompiler.component.LocationClangHighlightController.fieldLocationChanged(LocationClangHighlightController.java:53)
at ghidra.app.decompiler.component.DecompilerPanel$PendingHighlightUpdate.doUpdate(DecompilerPanel.java:1216)
at ghidra.app.decompiler.component.DecompilerPanel.lambda$new$0(DecompilerPanel.java:80)
at ghidra.util.task.SwingUpdateManager.swingDoWork(SwingUpdateManager.java:108)
at ghidra.util.task.AbstractSwingUpdateManager.swingExecutePendingWork(AbstractSwingUpdateManager.java:338)
at ghidra.util.task.AbstractSwingUpdateManager.checkForWork(AbstractSwingUpdateManager.java:278)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
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)
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
I did see the comment. I was unable to reproduce the issue, so it must be very output dependent.
@dragonmacher just checking, did you see that last comment I made in the other thread