-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Socket not closed, when GhidraBridge Object gets out of scope #65
Comments
I'm assuming that decode error is from the same code as the user who opened justfoxing/jfx_bridge#17 , yeah? If not, would love to see your code as well. Let's handle the debugging for that one in that issue. The exact time when the bridge socket gets closed is a bit messy - it happens when there's no references left to the bridge, and any bridged object will maintain a reference. If you're keeping something like remote_ghidra to use outside the block, the bridge it came over will stay alive as well. (Also, it's entirely possible I left bugs here - there's a strong potential for cyclic dependencies that would result in things living forever). It sounds like there's a range of issues here, with not enough info for me to see what's going on. My recommendation would be to not create multiple ghidra_bridges - instead, alter your code so that the first time you create a bridge, you keep it around to use for subsequent operations. Then, if you have issues after that, I'd love to be able to see your code as well as the error - that'd help me be able to give better advice. |
First, thanks for your fast reply
Right, some communication error.
I will refactor the code such, that I will keep one ghidra bridge alive and see if I still experience these hangs. If yes, I will try to provide code to reproduce it. |
Regarding, the opened sockets. If you execute this code multiple times in a jupyter notebook, the sockets are note closed, and a new one is opened on each execution.
Let's discuss the decode error in issue justfoxing/jfx_bridge#17 |
Ah, right, this is an issue with jupyter that's come up before (see #50). I think it might be to do with the underlying Ipython kernel retaining output history (the _# output variables recorded everytime a command/cell returns an output). This prevents those objects and anything they reference (including bridged objects) from actually being deleted (and the bridge connection stays open while any bridged objects it created are still around).
Only workaround I've identified was to restart the kernel to close the sockets.
If you place the bridge = ... line in its own cell at the top of the notebook and avoid rerunning that, subsequent cells can be rerun using that one bridge without having to create a new bridge each time.
|
Alternatively, you could try wrapping the bridge creation in something a little like the following, so that it only ever gets run once, regardless of how many times its cell is rerun.
|
… BridgeConn.send_cmd (and other functions) could try to put data on the socket at the same time. If there was enough data, the socket.send() might return partway, a thread switch might happen, and another thread might begin its message halfway through the first message. Attempting as a fix for justfoxing/ghidra_bridge#65
I have observed, that the socket to ghidra is not closed, when the GhidraBridge Object gets out of scope. It gets closed, when the whole python process terminates. We have a long running python process and do some ghidra operations from time to time via a remotifyied class:
In the log from Ghidra, we can see
WARNING:jfx_bridge.bridge:Handling connection from ('127.0.0.1', 55500)
each time the above code is called (with different port of course), but the connection gets not closed.Also we experience some hung ups now and then. Could that be related? We have also experienced hangs, when keeping the GhidraBridge Object alive across the different calls. What would be the correct was here?
At the same time, we are experiencing following error log:
The text was updated successfully, but these errors were encountered: