diff options
author | George Alexopoulos <giorgosalexo0@gmail.com> | 2024-11-15 10:05:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-15 10:05:51 (GMT) |
commit | 8717f792f7cc343599dc60daf80630cceb66145b (patch) | |
tree | 1b9ed5b2038a75c4bcec76de9568c7268c2c41fe /Misc | |
parent | c0f045f7fd3bb7ccf9828f4bfad55347d097fd41 (diff) | |
download | cpython-8717f792f7cc343599dc60daf80630cceb66145b.zip cpython-8717f792f7cc343599dc60daf80630cceb66145b.tar.gz cpython-8717f792f7cc343599dc60daf80630cceb66145b.tar.bz2 |
gh-126554: ctypes: Correctly handle NULL dlsym values (GH-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 <grgalex42@gmail.com>
Signed-off-by: Georgios Alexopoulos <grgalex@ba.uoa.gr>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/C_API/2024-11-07-20-24-58.gh-issue-126554.ri12eb.rst | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/C_API/2024-11-07-20-24-58.gh-issue-126554.ri12eb.rst b/Misc/NEWS.d/next/C_API/2024-11-07-20-24-58.gh-issue-126554.ri12eb.rst new file mode 100644 index 0000000..6af89c7 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2024-11-07-20-24-58.gh-issue-126554.ri12eb.rst @@ -0,0 +1,2 @@ +Fix error handling in :class:`ctypes.CDLL` objects +which could result in a crash in rare situations. |