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
Explicitly close the remote session #896
Conversation
I don't see any issue with merging this PR, but can you provide an example of how to trigger the issue you experienced in a first place? |
Consider something like this:
The second |
If that's the only case, it's possible we miss to catch that type of events. I'll investigate further later. |
There does not seem to be another event for that. The |
I found yesterday there is a new type of event called |
Well the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__del__
isn't guaranteed to be called when you run del
. It'll only be called when the garbage collector runs. This is better.
gef.py
Outdated
@@ -3507,6 +3507,7 @@ def exit_handler(_: "gdb.ExitedEvent") -> None: | |||
gef.session.qemu_mode = False | |||
if gef.session.remote: | |||
# make sure the tempdir is trashed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment doesn't make sense actually
gef.py
Outdated
@@ -3507,6 +3507,7 @@ def exit_handler(_: "gdb.ExitedEvent") -> None: | |||
gef.session.qemu_mode = False | |||
if gef.session.remote: | |||
# make sure the tempdir is trashed | |||
gef.session.remote.close() | |||
del(gef.session.remote) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
del is a keyword not a function, let's fix it.
@Grazfather The gc runs every time a refcount hits 0 which will be the case here. In any case it's out of the topic of this PR. |
No, the GC runs when it runs. If the refcount hits 0 that just means the GC will take care of it. Using |
I added a simple regression test and applied the other suggestions |
Description/Motivation/Screenshots
This solves an issue with the
__del__
magic method being called unreliably, in particular it will often get called just when creating a new remote session usinggef-remote
which causes an exception in the__del__
hook:Because of this exception gdb has to be restarted before using the
gef-remote
command again.Against which architecture was this tested ?
"Tested" indicates that the PR works and the unit test (i.e.
make test
) run passes without issue.Checklist
dev
branch, notmain
.