-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-137293: Ignore Exceptions when searching ELF File in Remote Debug #137309
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
base: main
Are you sure you want to change the base?
gh-137293: Ignore Exceptions when searching ELF File in Remote Debug #137309
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply 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.
Please add a news entry, and if possible, a test case. We can probably test this by running remote_exec
on a file with some weird permissions?
Python/remote_debug.h
Outdated
@@ -732,6 +732,9 @@ search_linux_map_for_section(proc_handle_t *handle, const char* secname, const c | |||
if (retval) { | |||
break; | |||
} | |||
if (PyErr_Occurred()){ |
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.
From my understanding, this should always be true at this point. If search_elf_file_for_section
returns 0
, there's an exception set.
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.
It might be overly defensive but could there be no exceptions in case section is null here?
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.
I'd have argued that was its own issue, but per discussion it seems we should just remove exceptions from search_elf_file_for_section
entirely. It's not called anywhere else.
I don't think we should print the exception. For example there are some normal conditions where we will find the target but we will have some exceptions while reading unrelated files and other cases and we don't want to confuse the users showing that error. What do you think @godlygeek ? |
I'm inclined to agree. Any problems encountered at this point aren't necessarily fatal, and there's no reason to ever report anything to the user if we go on to succeed. |
I might be off here but the problem with creating a test case for this is that when running |
You can try with a build with |
Ok, sure, no test is fine. I don't think |
Yeah that makes a lot of sense, I just removed the exceptions from |
Misc/NEWS.d/next/Core_and_Builtins/2025-08-01-20-31-30.gh-issue-137293.4x3JbV.rst
Outdated
Show resolved
Hide resolved
…e-137293.4x3JbV.rst Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Sweet, that sounds good, I just added my manual test details in the description |
I do not think that silencing all exceptions indiscriminately is a good idea. This may remove useful information. What if just add |
When calling
search_elf_file_for_section
fromsearch_linux_map_for_section
passing a file that either doesn't exist or can't be opened correctly for a variety of reasons, this will throw an exception regardless of whether that file containsPyRuntime
. The call tosearch_linux_map_for_section
can behave as expected if it does eventually open the file withPyRuntime
. After discussion, this fix removes exceptions fromsearch_linux_map_for_section
Tested manually with the following script:
Before:
Now