Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structure Editor NPE #2009

Closed
astrelsky opened this issue Jun 19, 2020 · 2 comments
Closed

Structure Editor NPE #2009

astrelsky opened this issue Jun 19, 2020 · 2 comments
Assignees
Labels
Feature: Structure Editor Status: Internal This is being tracked internally by the Ghidra team Type: Bug Something isn't working
Milestone

Comments

@astrelsky
Copy link
Contributor

Describe the bug
Adding undefined bytes to fast to manually fix #2007 results in a NPE.

To Reproduce
Steps to reproduce the behavior:

  1. Get a structure with a field that is to big.
  2. Click add undefined byte as fast as you can (before the change has propagated)
  3. Be greeted by NPE

Expected behavior
No NPE

Attachments

stacktrace

Uncaught Exception!
NullPointerException - Cannot invoke "ghidra.program.model.data.DataTypeComponent.getDataType()" because "comp" is null
java.lang.NullPointerException: Cannot invoke "ghidra.program.model.data.DataTypeComponent.getDataType()" because "comp" is null
at ghidra.app.plugin.core.compositeeditor.StructureEditorModel.isDuplicateAllowed(StructureEditorModel.java:662)
at ghidra.app.plugin.core.compositeeditor.DuplicateAction.adjustEnablement(DuplicateAction.java:73)
at ghidra.app.plugin.core.compositeeditor.CompositeEditorTableAction.selectionChanged(CompositeEditorTableAction.java:105)
at ghidra.app.plugin.core.compositeeditor.CompositeViewerModel.lambda$selectionChanged$4(CompositeViewerModel.java:1391)
at ghidra.app.plugin.core.compositeeditor.CompositeViewerModel.lambda$updatingSelection$3(CompositeViewerModel.java:1378)
at ghidra.util.Swing.runIfSwingOrRunLater(Swing.java:124)
at ghidra.app.plugin.core.compositeeditor.CompositeViewerModel.swing(CompositeViewerModel.java:1401)
at ghidra.app.plugin.core.compositeeditor.CompositeViewerModel.updatingSelection(CompositeViewerModel.java:1374)
at ghidra.app.plugin.core.compositeeditor.CompositeViewerModel.selectionChanged(CompositeViewerModel.java:1388)
at ghidra.app.plugin.core.compositeeditor.CompEditorModel.setSelection(CompEditorModel.java:189)
at ghidra.app.plugin.core.compositeeditor.CompositeEditorPanel.lambda$createTable$5(CompositeEditorPanel.java:574)
at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:219)
at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:186)
at java.desktop/javax.swing.DefaultListSelectionModel.setValueIsAdjusting(DefaultListSelectionModel.java:723)
at java.desktop/javax.swing.plaf.basic.BasicTableUI$Handler.setValueIsAdjusting(BasicTableUI.java:972)
at java.desktop/javax.swing.plaf.basic.BasicTableUI$Handler.mouseReleased(BasicTableUI.java:1185)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6636)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
at java.desktop/java.awt.Component.processEvent(Component.java:6401)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5012)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4919)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4548)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4489)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2764)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
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(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
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: 2020-Jun-09 1205 EDT
Ghidra Version: 9.2
Java Home: C:\Program Files\Java\jdk-14.0.1
JVM Version: Oracle Corporation 14.0.1
OS: Windows 10 10.0 amd64
Workstation: 10.0.0.31

Environment (please complete the following information):
see stack trace

@dev747368 dev747368 added the Type: Bug Something isn't working label Jun 23, 2020
@dev747368
Copy link
Collaborator

StructureEditorModel.insert(), line 973 bumps the row index +1 to keep the current row focused, but line 979 might then delete the newly added undefined component when it gets merged into the badly-sized structure that was located just before the newly inserted undefined. (ie. the added row gets removed, but the indexes aren't updated)
This is where the problems start.
Row is now incorrect, later causing isDuplicateAllowed() to NPE because it gets a bad row index.

@ghidra1 ghidra1 self-assigned this Jun 6, 2022
@ghidra1 ghidra1 added the Status: Prioritize This is currently being prioritized label Jun 6, 2022
@ghidra1
Copy link
Collaborator

ghidra1 commented Jun 6, 2022

See GP-60 (internal ticket)

@ghidra1 ghidra1 added Status: Internal This is being tracked internally by the Ghidra team and removed Status: Prioritize This is currently being prioritized labels Jun 9, 2022
@ghidra1 ghidra1 added this to the 10.1.5 milestone Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Structure Editor Status: Internal This is being tracked internally by the Ghidra team Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants