exbin / bined-intellij-plugin

Hex viewer/editor plugin for JetBrains IntelliJ platform
https://bined.exbin.org/intellij-plugin
Apache License 2.0
59 stars 9 forks source link

NullPointerException when trying to hex-view bytearray in Debug mode #27

Closed mazen-mardini closed 4 years ago

mazen-mardini commented 4 years ago

Hello,

I'm getting the following exception when trying to open the hex-editor for a bytearray variable in Debug-mode (Python/PyCharm):

java.lang.NullPointerException
    at org.exbin.bined.intellij.debug.DebugViewBinaryAction$PyValueFuture.<init>(DebugViewBinaryAction.java:459)
    at org.exbin.bined.intellij.debug.DebugViewBinaryAction$DataDialog.identifyData(DebugViewBinaryAction.java:216)
    at org.exbin.bined.intellij.debug.DebugViewBinaryAction$DataDialog.<init>(DebugViewBinaryAction.java:185)
    at org.exbin.bined.intellij.debug.DebugViewBinaryAction$DataDialog.<init>(DebugViewBinaryAction.java:164)
    at org.exbin.bined.intellij.debug.DebugViewBinaryAction$1.lambda$handleInCollector$0(DebugViewBinaryAction.java:106)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:309)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:441)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:424)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:407)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:906)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:779)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:422)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:698)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:421)
    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)
hajdam commented 4 years ago

Hi, I'll try to look into this, but I think this was changed between recent versions of PyCharm. Are you using stable or development build (edit: of the plugin)?

Actually reworking / adding support for debug variables / more idea variants is main change planned for next version of the plugin...

mazen-mardini commented 4 years ago

Thanks for a great plugin and a quick response!

I'm running the following version:

PyCharm 2019.3 (Community Edition)
Build #PC-193.5233.109, built on November 28, 2019
Runtime version: 11.0.4+10-b520.11 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

PyCharm is a stable build. I have it installed as a Snap-package on Ubuntu:

Name                     Version                     Rev   Tracking  Publisher           Notes
pycharm-community        2019.3                      169   stable    jetbrains✓          classic

The plugin is the latest snapshot: 0.2.2 [2019-12-04]

hajdam commented 4 years ago

I was not able to test this so far. In my test python script, I have z = bytearray(500) which seems to be working for basic binary view. Not sure if my environment is different or there is some other means of declaring bytearray type in Python as I'm not familiar with this language enough I'm afraid. Tested with PyCharm Community 2019.3.1 on Fedora 64 bit.

If possible please provide sample python script where view as binary fails.

I tried to provide some modified build with guessing attempt to workaround this, but I have strong doubts it will help.

mazen-mardini commented 4 years ago

You could use this script:

def f():
    b = bytearray()
    b += b'0000000'
    print(b)

f()

Set the breakpoint on the print-call, run in debug-mode and then right-click the local variable b in the debugger and press View as Binary. That triggers the bug.

EDIT: I forgot one detail. I'm using PyPy 3.6.

hajdam commented 4 years ago

I tried to fix this in version 0.2.2. Not sure if all forms of content are properly supported, thou.