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

JISAutoDetect Encoding UnsupportedOperationException #1358

Closed
astrelsky opened this issue Dec 18, 2019 · 3 comments
Closed

JISAutoDetect Encoding UnsupportedOperationException #1358

astrelsky opened this issue Dec 18, 2019 · 3 comments
Assignees
Labels
Feature: Data Types Type: Bug Something isn't working
Milestone

Comments

@astrelsky
Copy link
Contributor

Describe the bug
Attempting to change the encoding of data thought to be a string to JISAutoDetect has resulted in an UnsupportedOperationException

To Reproduce
Steps to reproduce the behavior:

  1. Data is likely not a string. I'm not certain reproducing this is actually necessary.

Expected behavior
If a string has not yet been defined at the data location simply fail to create the data. If data exists notify the user that the encoding couldn't be detected/applied.

Environment (please complete the following information):

  • OS: Microsoft Windows [Version 10.0.18363.535]
  • Java Version: 13.0.1
  • Ghidra Version: 9.2
stack trace
ERROR Listing Field Exception: Exception occured while rendering 'Operands' field  (ErrorFieldMouseHandler.java:42) 
java.lang.UnsupportedOperationException: null
        at sun.nio.cs.ext.JISAutoDetect.newEncoder(JISAutoDetect.java:79) ~[jdk.charsets:?]
        at java.lang.StringCoding.encode(StringCoding.java:444) ~[?:?]
        at java.lang.String.getBytes(String.java:980) ~[?:?]
        at ghidra.program.model.data.StringDataInstance.convertStringToBytes(StringDataInstance.java:575) ~[SoftwareModeling.jar:?]
        at ghidra.program.model.data.StringDataInstance.getStringRepresentation(StringDataInstance.java:676) ~[SoftwareModeling.jar:?]
        at ghidra.program.model.data.AbstractStringDataType.getRepresentation(AbstractStringDataType.java:232) ~[SoftwareModeling.jar:?]
        at ghidra.program.model.listing.CodeUnitFormat.getDataValueRepresentation(CodeUnitFormat.java:1064) ~[Base.jar:?]
        at ghidra.app.util.viewer.field.OperandFieldHelper.getFieldForData(OperandFieldHelper.java:357) ~[Base.jar:?]    
        at ghidra.app.util.viewer.field.OperandFieldHelper.getField(OperandFieldHelper.java:199) ~[Base.jar:?]
        at ghidra.app.util.viewer.field.OperandFieldFactory.getField(OperandFieldFactory.java:59) ~[Base.jar:?]
        at ghidra.app.util.viewer.format.Row.getLayout(FieldFormatModel.java:502) ~[Base.jar:?]
        at ghidra.app.util.viewer.format.FieldFormatModel.addLayouts(FieldFormatModel.java:102) ~[Base.jar:?]
        at ghidra.app.util.viewer.listingpanel.ProgramBigListingModel.doGetLayout(ProgramBigListingModel.java:189) ~[Base.jar:?]
        at ghidra.app.util.viewer.listingpanel.ProgramBigListingModel.getLayout(ProgramBigListingModel.java:124) ~[Base.jar:?]
        at ghidra.app.util.viewer.listingpanel.ListingModelAdapter.getLayout(ListingModelAdapter.java:131) ~[Base.jar:?] 
        at docking.widgets.fieldpanel.FieldPanel$CursorHandler.doSetCursorPosition(FieldPanel.java:1919) ~[Docking.jar:?]
        at docking.widgets.fieldpanel.FieldPanel$CursorHandler.updateCursor(FieldPanel.java:2119) ~[Docking.jar:?]       
        at docking.widgets.fieldpanel.FieldPanel.modelSizeChanged(FieldPanel.java:979) ~[Docking.jar:?]
        at ghidra.app.util.viewer.listingpanel.ListingModelAdapter.resetIndexMap(ListingModelAdapter.java:455) ~[Base.jar:?]
        at ghidra.app.util.viewer.listingpanel.ListingModelAdapter.lambda$new$0(ListingModelAdapter.java:60) ~[Base.jar:?]
        at ghidra.util.task.SwingUpdateManager.doWork(SwingUpdateManager.java:309) ~[Generic.jar:?]
        at ghidra.util.task.SwingUpdateManager.checkForWork(SwingUpdateManager.java:263) ~[Generic.jar:?]
        at ghidra.util.Swing.doRun(Swing.java:295) ~[Utility.jar:?]
        at ghidra.util.Swing.runNow(Swing.java:211) ~[Utility.jar:?]
        at ghidra.util.Swing.runNow(Swing.java:166) ~[Utility.jar:?]
        at ghidra.util.SystemUtilities.runSwingNow(SystemUtilities.java:225) ~[Utility.jar:?]
        at ghidra.util.task.SwingUpdateManager.updateNow(SwingUpdateManager.java:191) ~[Generic.jar:?]
        at ghidra.app.util.viewer.listingpanel.ListingModelAdapter.dataChanged(ListingModelAdapter.java:184) ~[Base.jar:?]
        at ghidra.app.util.viewer.listingpanel.ProgramBigListingModel.notifyDataChanged(ProgramBigListingModel.java:505) 
~[Base.jar:?]
        at ghidra.app.util.viewer.listingpanel.ProgramBigListingModel.domainObjectChanged(ProgramBigListingModel.java:559) ~[Base.jar:?]
        at ghidra.framework.data.DomainObjectChangeSupport.notifyEvent(DomainObjectChangeSupport.java:120) ~[Project.jar:?]
        at ghidra.framework.data.DomainObjectChangeSupport.sendEventNow(DomainObjectChangeSupport.java:85) ~[Project.jar:?]
        at ghidra.framework.data.DomainObjectChangeSupport.lambda$flush$3(DomainObjectChangeSupport.java:143) ~[Project.jar:?]
        at ghidra.util.Swing.doRun(Swing.java:295) ~[Utility.jar:?]
        at ghidra.util.Swing.runNow(Swing.java:211) ~[Utility.jar:?]
        at ghidra.util.Swing.runNow(Swing.java:166) ~[Utility.jar:?]
        at ghidra.util.SystemUtilities.runSwingNow(SystemUtilities.java:225) ~[Utility.jar:?]
        at ghidra.framework.data.DomainObjectChangeSupport.flush(DomainObjectChangeSupport.java:143) ~[Project.jar:?]    
        at ghidra.framework.data.DomainObjectAdapter.flushEvents(DomainObjectAdapter.java:245) ~[Project.jar:?]
        at ghidra.framework.data.DomainObjectTransactionManager.lambda$flushDomainObjectEvents$0(DomainObjectTransactionManager.java:137) ~[Project.jar:?]
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) [?:?]
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) [?:?]
        at java.awt.EventQueue$4.run(EventQueue.java:721) [?:?]
        at java.awt.EventQueue$4.run(EventQueue.java:715) [?:?]
        at java.security.AccessController.doPrivileged(AccessController.java:391) ~[?:?]
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) ~[?:?]
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:740) ~[?:?]
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) ~[?:?]
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) ~[?:?]
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:117) ~[?:?]
        at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190) ~[?:?]
        at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235) ~[?:?]
        at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233) ~[?:?]
        at java.security.AccessController.doPrivileged(AccessController.java:312) [?:?]
        at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233) ~[?:?]
        at java.awt.Dialog.show(Dialog.java:1070) ~[?:?]
        at java.awt.Component.show(Component.java:1716) ~[?:?]
        at java.awt.Component.setVisible(Component.java:1663) ~[?:?]
        at java.awt.Window.setVisible(Window.java:1021) ~[?:?]
        at java.awt.Dialog.setVisible(Dialog.java:1005) ~[?:?]
        at docking.DockingDialog.setVisible(DockingDialog.java:317) ~[Docking.jar:?]
        at docking.DockingWindowManager.lambda$doShowDialog$6(DockingWindowManager.java:1720) ~[Docking.jar:?]
        at ghidra.util.Swing.doRun(Swing.java:295) ~[Utility.jar:?]
        at ghidra.util.Swing.runNow(Swing.java:211) ~[Utility.jar:?]
        at ghidra.util.Swing.runNow(Swing.java:166) ~[Utility.jar:?]
        at ghidra.util.SystemUtilities.runSwingNow(SystemUtilities.java:225) ~[Utility.jar:?]
        at docking.DockingWindowManager.doShowDialog(DockingWindowManager.java:1724) ~[Docking.jar:?]
        at docking.DockingWindowManager.showDialog(DockingWindowManager.java:1756) ~[Docking.jar:?]
        at docking.AbstractDockingTool.showDialog(AbstractDockingTool.java:155) ~[Docking.jar:?]
        at ghidra.app.plugin.core.data.DataPlugin.dataSettingsCallback(DataPlugin.java:672) ~[Base.jar:?]
        at ghidra.app.plugin.core.data.DataPlugin$1.actionPerformed(DataPlugin.java:140) ~[Base.jar:?]
        at docking.PopupMenuHandler$1.run(PopupMenuHandler.java:61) ~[Docking.jar:?]
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) ~[?:?]
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) ~[?:?]
        at java.awt.EventQueue$4.run(EventQueue.java:721) ~[?:?]
        at java.awt.EventQueue$4.run(EventQueue.java:715) ~[?:?]
        at java.security.AccessController.doPrivileged(AccessController.java:391) [?:?]
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) [?:?] 
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:740) [?:?]
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) [?:?]
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) [?:?]
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) [?:?]
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) [?:?]
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:?]
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) [?:?]
@dev747368 dev747368 self-assigned this Dec 18, 2019
@ryanmkurtz ryanmkurtz added Feature: Data Types Type: Bug Something isn't working labels Dec 18, 2019
@dev747368
Copy link
Collaborator

That character set (x-jisautodetect) is a special character set and it has a flag that says "I don't support encoding", which is something Ghidra was trying to use when it runs into a bad character in the decoded string.
The fix will be to query that flag before trying to use the feature, and if we can't use the feature to get the original bytes of the bad character, fall back to embedding a "???" in the output in place of the bad character.

GhidorahRex pushed a commit that referenced this issue Jan 15, 2020
Fixes github issue #1358.


Some character sets don't support the encoding operation.
@dev747368
Copy link
Collaborator

This should have been fixed by commit 93bcabe

@astrelsky
Copy link
Contributor Author

This should have been fixed by commit 93bcabe

Cool. Unfortunately I can't confirm as I never recorded where I encountered it.

@ryanmkurtz ryanmkurtz added this to the 9.2 milestone Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Data Types Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants