question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Decompiler sometimes fails to highlight matching braces

See original GitHub issue

Describe 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:

  1. Decompile provided example (function _breaks)
  2. Go to line 24 and click on the else opening bracket, above lab1

Expected behavior Java exception window appears with java.util.EmptyStackException (Clicking on the bottom bracket works, and succesfully highlights the top one)

Screenshots example

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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dragonmachercommented, Aug 25, 2022

I did see the comment. I was unable to reproduce the issue, so it must be very output dependent.

0reactions
mumbelcommented, Aug 25, 2022

@dragonmacher just checking, did you see that last comment I made in the other thread

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vim finds incorrect matching bracket when using
You have an actual syntax error with a mismatched paren or curly brace somewhere. You have a value in cpoptions that prevents semi-intelligent...
Read more >
New text editor ignores the "Highlight matching braces" setting
In the new text editor in Visual Studio for Mac 8.1, putting the cursor next to a brace character will always highlight the...
Read more >
Highlight Matching Braces/Parentheses
The Highlight matching braces/parenthesis setting has a serious implication that gets its own Top 10 listing.
Read more >
make the compiler friendlier by matching brackets
You need to click next to a bracket and then the matching one of the pair is highlighted. Another help for bigger sketches...
Read more >
How to find matching braces in IDA's decompiled code?
There is no way to do this by default. Checkout the Hexlight plugin by Milan Bohacek. It will highlight the line with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found