Ghidra: Drop Failed. Could not transfer data

Created on 30 Dec 2019  路  15Comments  路  Source: NationalSecurityAgency/ghidra

Describe the bug
Attempting to drag and drop an imported file from the project into the code browser results in an Assert Exception

To Reproduce
Steps to reproduce the behavior:

  1. Open Code Browser tool.
  2. Drag and drop imported file from project into code browser.
  3. Receive Assert Exception.

Environment (please complete the following information):

  • OS: Microsoft Windows [Version 10.0.18363.535]
  • Java Version: 13.0.1
  • Ghidra Version: 9.2 cbe5b9e9cae03ce4dea117799afc03e4ad32a488
GUI Bug

All 15 comments

Were you running Ghidra in a debugging session from Eclipse?

Were you running Ghidra in a debugging session from Eclipse?

vscode-java-debug but yet it was a debug session. I didn't check outside of the debugger though.

Yeah, we've seen it a few times recently when running in a debug session, but haven't figured out the steps to reproduce it yet. From looking at the code, the only thing that makes sense is that a 'constant' static variable is getting re-initialized by the debugger and causing the object instance comparisons to fail.
If you can reproduce it, please post steps.

Yeah, we've seen it a few times recently when running in a debug session, but haven't figured out the steps to reproduce it yet. From looking at the code, the only thing that makes sense is that a 'constant' static variable is getting re-initialized by the debugger and causing the object instance comparisons to fail.
If you can reproduce it, please post steps.

It occurs every time I try to drag and drop a file from the project to the code browser.

Add some info to the assert message (in DataTreeDragNDropHandler.java line 161'ish) - ie. the class of the flavor, and a few of its properties... ie. mimetype, primary type, subtype, etc.

@astrelsky Assuming you can edit the code, we would like you comment out the AssertException at line 161 to see if the drop operation will successfully complete.

Sorry I just got back and was tracing back what the unexpected DataFlavor is and where its coming from and it appears to be linuxFileUrlFlavor which is added in the code below.
https://github.com/NationalSecurityAgency/ghidra/blob/cbe5b9e9cae03ce4dea117799afc03e4ad32a488/Ghidra/Features/Base/src/main/java/ghidra/app/util/GhidraFileOpenDataFlavorHandlerService.java#L27-L29

I effectively ignored the AssertionException by just setting error to false in the debugging session so it would continue on as if nothing happened. Unfortunately I ended up with a NullPointerException.

I'll try skipping over that flavor to see if gets the correct one.

Also I initially didn't provide much information as I had believed it to be simple to reproduce, should have know better.

So, skipping over that flavor allowed the correct one to be used. It appears that linuxFileUrlFlavor shouldn't be added on a non linux platform maybe?

https://github.com/NationalSecurityAgency/ghidra/blob/cbe5b9e9cae03ce4dea117799afc03e4ad32a488/Ghidra/Framework/Docking/src/main/java/docking/dnd/DropTgtAdapter.java#L127-L134

I simply incremented i in the for loop when it got to the linuxFileUrlFlavor and it resulted in proper functionality for that drop.

Did this operation break for you recently?

Did this operation break for you recently?

Yes. I would say within the last week or so. Definitely sometime in December.

The change that broke this was related to allowing the user to copy program names to the clipboard from the Front End. Now that one of the Data Flavors is a String, the LinuxFileUrlHandler is attempting to process the dragged Front End node as a String, which never happened before. My guess is that the string name of the tree node is in an unexpected format for the file handler.

The correct fix will be related to having the drop operation better understand how to handle a dragged String.

Is there actually a valid occurrence of a represented String?

For some OSes, a file drag from the OS to Ghidra will produce a String flavor. We then convert the String to a file path.

I'd like you to verify something. Please change https://github.com/NationalSecurityAgency/ghidra/blob/cbe5b9e9cae03ce4dea117799afc03e4ad32a488/Ghidra/Framework/Docking/src/main/java/docking/dnd/DropTgtAdapter.java

to add this method:

    private void sortFlavors() {
        Arrays.sort(dropFlavors, (f1, f2) -> {

            if (f1 instanceof GenericDataFlavor) {
                if (f2 instanceof GenericDataFlavor) {
                    return f1.getHumanPresentableName().compareTo(f2.getHumanPresentableName());
                }
                return -1;
            }
            else if (f2 instanceof GenericDataFlavor) {
                return 1;
            }

            return 0;

        });
    }

Then add a call to that method below lines 52 and 59, where the dropFlavors variable is set.

I think the current setup will work as intended if we handle the flavors in the preferred order.

Is there actually a valid occurrence of a represented String?

For some OSes, a file drag from the OS to Ghidra will produce a String flavor. We then convert the String to a file path.

I'd like you to verify something. Please change https://github.com/NationalSecurityAgency/ghidra/blob/cbe5b9e9cae03ce4dea117799afc03e4ad32a488/Ghidra/Framework/Docking/src/main/java/docking/dnd/DropTgtAdapter.java

to add this method:

-snip-

Then add a call to that method below lines 52 and 59, where the dropFlavors variable is set.

I think the current setup will work as intended if we handle the flavors in the preferred order.

That did the trick. Tried both single and multiple file drops and they worked without a problem.

Thanks for the help. We will put a fix in for this.

Thanks for the help. We will put a fix in for this.

No problem

@dragonmacher Not sure if it's better to sort them, or to just add the linuxFileUrl last in the first place.

https://github.com/NationalSecurityAgency/ghidra/blob/cbe5b9e9cae03ce4dea117799afc03e4ad32a488/Ghidra/Features/Base/src/main/java/ghidra/app/util/GhidraFileOpenDataFlavorHandlerService.java#L24-L45

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niedabao1 picture niedabao1  路  23Comments

mewmew picture mewmew  路  16Comments

ghost picture ghost  路  29Comments

Piruzzolo picture Piruzzolo  路  19Comments

woachk picture woachk  路  33Comments