NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.73k stars 5.89k forks source link

Drag and drop not working in KDE and wayland #4118

Open tati-frog opened 2 years ago

tati-frog commented 2 years ago

Describe the bug When I drag and drop a file in the project explorer it throws the following exception.

Owner failed to convert data
java.io.IOException: Owner failed to convert data
    at java.desktop/sun.awt.X11.XSelection.validateDataGetter(XSelection.java:444)
    at java.desktop/sun.awt.X11.XSelection.getData(XSelection.java:305)
    at java.desktop/sun.awt.X11.XDnDDropTargetProtocol.getData(XDnDDropTargetProtocol.java:879)
    at java.desktop/sun.awt.X11.XDropTargetContextPeer.getNativeData(XDropTargetContextPeer.java:152)
    at java.desktop/sun.awt.dnd.SunDropTargetContextPeer.getTransferData(SunDropTargetContextPeer.java:266)
    at java.desktop/sun.awt.datatransfer.TransferableProxy.getTransferData(TransferableProxy.java:73)
    at java.desktop/java.awt.dnd.DropTargetContext$TransferableProxy.getTransferData(DropTargetContext.java:386)
    at ghidra.framework.main.datatree.DataTreeDragNDropHandler.handleDrop(DataTreeDragNDropHandler.java:92)
    at ghidra.framework.main.datatree.DataTreeDragNDropHandler.drop(DataTreeDragNDropHandler.java:82)
    at docking.widgets.tree.internal.GTreeDragNDropAdapter.drop(GTreeDragNDropAdapter.java:276)
    at java.desktop/java.awt.dnd.DropTarget.drop(DropTarget.java:452)
    at ghidra.util.CascadedDropTarget.drop(CascadedDropTarget.java:53)
    at java.desktop/sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(SunDropTargetContextPeer.java:547)
    at java.desktop/sun.awt.X11.XDropTargetContextPeer.processDropMessage(XDropTargetContextPeer.java:185)
    at java.desktop/sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchDropEvent(SunDropTargetContextPeer.java:863)
    at java.desktop/sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(SunDropTargetContextPeer.java:787)
    at java.desktop/sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTargetEvent.java:48)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4876)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
    at java.desktop/java.awt.LightweightDispatcher.processDropTargetEvent(Container.java:4621)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4483)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
    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(Native Method)
    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(Native Method)
    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: 2022-Jan-25 1526 EST
Ghidra Version: 10.1.2
Java Home: /usr/lib/jvm/java-11-openjdk-11.0.14.1.1-5.fc35.x86_64
JVM Version: Red Hat, Inc. 11.0.14.1
OS: Linux 5.16.18-200.fc35.x86_64 amd64
Workstation: fedora

To Reproduce Steps to reproduce the behavior:

  1. Run a wayland session.
  2. Drag and drop a file into the project explorer.

Expected behavior I expect the file to get imported as normal.

Environment (please complete the following information):

dev747368 commented 2 years ago

I can't duplicate with fresh install of fedora 35 & ghidra 10.1.2.

I'm using Amazon Corretto 11 though. Could you try that?

tati-frog commented 2 years ago

Mmm, nope it still throws an exception

Owner failed to convert data
java.io.IOException: Owner failed to convert data
    at java.desktop/sun.awt.X11.XSelection.validateDataGetter(XSelection.java:444)
    at java.desktop/sun.awt.X11.XSelection.getData(XSelection.java:305)
    at java.desktop/sun.awt.X11.XDnDDropTargetProtocol.getData(XDnDDropTargetProtocol.java:879)
    at java.desktop/sun.awt.X11.XDropTargetContextPeer.getNativeData(XDropTargetContextPeer.java:152)
    at java.desktop/sun.awt.dnd.SunDropTargetContextPeer.getTransferData(SunDropTargetContextPeer.java:266)
    at java.desktop/sun.awt.datatransfer.TransferableProxy.getTransferData(TransferableProxy.java:73)
    at java.desktop/java.awt.dnd.DropTargetContext$TransferableProxy.getTransferData(DropTargetContext.java:386)
    at ghidra.framework.main.datatree.DataTreeDragNDropHandler.handleDrop(DataTreeDragNDropHandler.java:92)
    at ghidra.framework.main.datatree.DataTreeDragNDropHandler.drop(DataTreeDragNDropHandler.java:82)
    at docking.widgets.tree.internal.GTreeDragNDropAdapter.drop(GTreeDragNDropAdapter.java:276)
    at java.desktop/java.awt.dnd.DropTarget.drop(DropTarget.java:452)
    at ghidra.util.CascadedDropTarget.drop(CascadedDropTarget.java:53)
    at java.desktop/sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(SunDropTargetContextPeer.java:547)
    at java.desktop/sun.awt.X11.XDropTargetContextPeer.processDropMessage(XDropTargetContextPeer.java:185)
    at java.desktop/sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchDropEvent(SunDropTargetContextPeer.java:863)
    at java.desktop/sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(SunDropTargetContextPeer.java:787)
    at java.desktop/sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTargetEvent.java:48)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4876)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
    at java.desktop/java.awt.LightweightDispatcher.processDropTargetEvent(Container.java:4621)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4483)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
    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(Native Method)
    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(Native Method)
    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: 2022-Jan-25 1526 EST
Ghidra Version: 10.1.2
Java Home: /usr/lib/jvm/java-11-amazon-corretto
JVM Version: Amazon.com Inc. 11.0.14.1
OS: Linux 5.16.18-200.fc35.x86_64 amd64
Workstation: fedora

I think I should have mentioned that I'm on kde.

dev747368 commented 2 years ago

Can dup with KDE on Fedora.

dev747368 commented 2 years ago

My gut feeling is this is a bug at the jdk / desktop level that Ghidra can't fix on its side. Inspecting the values of the various drag-n-drop context variables during the handleDrop() doesn't show anything obvious.

I also noted that the source icon (if dragging from the desktop) disappears for a moment after dropping on ghidra (in case anyone see it and panics like I did).