nccgroup / Cartographer

Code Coverage Exploration Plugin for Ghidra
Apache License 2.0
317 stars 26 forks source link

Index -1 out of bounds for length 95 #2

Closed sk-zk closed 5 months ago

sk-zk commented 1 year ago

Describe the bug Attempting to open a drcov log fails with the following exception. The "Select a Coverage Module" dialog box does not appear.

Index -1 out of bounds for length 95
java.lang.AssertionError: Index -1 out of bounds for length 95
    at cartographer.CoverageFile.<init>(CoverageFile.java:137)
    at cartographer.CartographerPlugin$2.lambda$actionPerformed$0(CartographerPlugin.java:296)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at cartographer.CartographerPlugin$2.actionPerformed(CartographerPlugin.java:291)
    at docking.DockingActionProxy.actionPerformed(DockingActionProxy.java:47)
    at docking.MenuBarMenuHandler.lambda$processMenuAction$0(MenuBarMenuHandler.java:64)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
    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:742)
    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)

---------------------------------------------------
Build Date: 2023-Jul-11 1640 EDT
Ghidra Version: 10.3.2
Java Home: E:\jdk-19
JVM Version: Oracle Corporation 19.0.1
OS: Windows 10 10.0 amd64
Workstation:

To Reproduce I'll be using Minetest as an example here because it's the first FOSS program I found which can produce this exception.

  1. Run drcov on minetest.exe. Whether you launch it through drcov or attach it to a running process doesn't make a difference.
  2. Attempt to load the coverage log at Tools > Code Coverage > Load Code Coverage File(s).
  3. The error message seen above appears.

Expected behavior The plugin loads the coverage log.

20urc3 commented 9 months ago

Hi, thanks for the tool. Same issue here.

Index -1 out of bounds for length 160
java.lang.AssertionError: Index -1 out of bounds for length 160
    at cartographer.CoverageFile.<init>(CoverageFile.java:137)
    at cartographer.CartographerPlugin$2.lambda$actionPerformed$0(CartographerPlugin.java:296)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at cartographer.CartographerPlugin$2.actionPerformed(CartographerPlugin.java:291)
    at docking.DockingActionProxy.actionPerformed(DockingActionProxy.java:47)
    at docking.MenuBarMenuHandler.lambda$processMenuAction$0(MenuBarMenuHandler.java:60)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
    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)

---------------------------------------------------
Build Date: 2023-Sep-28 1301 EDT
Ghidra Version: 10.4
Java Home: C:\Program Files\Java\jdk-20
JVM Version: Oracle Corporation 20.0.2
OS: Windows 10 10.0 amd64
Workstation: DESKTOP

EDIT: Tested on Ghidra 10.3 / 10.3.2 / 10.4 => Present in all version

20urc3 commented 9 months ago

@sk-zk try to dump_binary instead of dump_text with drrun -t drcov and tell me if it works for you now ? :)

sk-zk commented 5 months ago

dump_binary is the default so it was already enabled.