-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
[3.12] gh-126554: ctypes: Correctly handle NULL dlsym values (GH-126555) #127764
[3.12] gh-126554: ctypes: Correctly handle NULL dlsym values (GH-126555) #127764
Conversation
…-126555) For dlsym(), a return value of NULL does not necessarily indicate an error [1]. Therefore, to avoid using stale (or NULL) dlerror() values, we must: 1. clear the previous error state by calling dlerror() 2. call dlsym() 3. call dlerror() If the return value of dlerror() is not NULL, an error occured. In ctypes we choose to treat a NULL return value from dlsym() as a "not found" error. This is the same as the fallback message we use on Windows, Cygwin or when getting/formatting the error reason fails. [1]: https://man7.org/linux/man-pages/man3/dlsym.3.html Signed-off-by: Georgios Alexopoulos <[email protected]> Signed-off-by: Georgios Alexopoulos <[email protected]> Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
I've opened the backport PR so that we are consistent with backporting. But the diff is quite non-trivial since the backport was not automatic. So if you don't want to lose time, we can just say "let's not backport 3.12" (even though you said that you didn't care). I'm marking the PR as a draft so that we don't merge by mistake. EDIT 1: Ok I think I messed up the backport. |
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.
Thanks, @picnixz.
For dlsym(), a return value of NULL does not necessarily indicate
an error 1.
Therefore, to avoid using stale (or NULL) dlerror() values, we must:
If the return value of dlerror() is not NULL, an error occured.
In ctypes we choose to treat a NULL return value from dlsym()
as a "not found" error. This is the same as the fallback
message we use on Windows, Cygwin or when getting/formatting
the error reason fails.
(cherry picked from commit 8717f79)
Co-authored-by: George Alexopoulos [email protected]
Signed-off-by: Georgios Alexopoulos [email protected]
Signed-off-by: Georgios Alexopoulos [email protected]
Co-authored-by: Peter Bierma [email protected]
Co-authored-by: Bénédikt Tran [email protected]
Co-authored-by: Petr Viktorin [email protected]