Skip to content

gh-133157: remove use of _Py_NO_SANITIZE_UNDEFINED in faulthandler - #134047

Merged
picnixz merged 3 commits into
python:mainfrom
picnixz:fix/ubsan/faulthandler-133157
May 18, 2025
Merged

picnixz merged 3 commits into
python:mainfrom
picnixz:fix/ubsan/faulthandler-133157

Conversation

@picnixz

@picnixz picnixz commented May 15, 2025 •

Copy link
Copy Markdown
Member
  • remove _read_null() as it's a tricky one (and the compiler didn't seem to complain)
  • instead of using 1/0 arithmetic, we explicitly raise SIGFPE
- reading from NULL is no more an undefined behavior for C11
- instead of using 1/0 arithmetic, we explicitly raise SIGFPE
Comment thread Modules/faulthandler.c Resolved
Comment thread Modules/faulthandler.c Resolved
Comment thread Modules/faulthandler.c Resolved
picnixz added 2 commits May 15, 2025 17:30
Reading from NULL is an undefined behavior and `faulthandler`
should not check for low-level C about undefined behaviors.
@picnixz
picnixz requested a review from vstinner May 16, 2025 09:03
@picnixz

picnixz commented May 16, 2025

Copy link
Copy Markdown
Member Author

Should I actually add a NEWS entry? the function was not documented but it had a docstring.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinner

Copy link
Copy Markdown
Member

Should I actually add a NEWS entry? the function was not documented but it had a docstring.

It doesn't need a NEWS entry since it's a private function written for test_faulthandler.

@picnixz
picnixz merged commit 0a160bf into python:main May 18, 2025
@picnixz
picnixz deleted the fix/ubsan/faulthandler-133157 branch May 18, 2025 08:16
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
…thandler` (python#134047)

In `faulthandler_sigfpe()`, instead of using 1/0 arithmetic, we explicitly raise SIGFPE.
We also remove `faulthandler._read_null()` since reading from NULL is an undefined
behavior and `faulthandler` should not check for low-level C undefined behaviors.
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
…thandler` (python#134047)

In `faulthandler_sigfpe()`, instead of using 1/0 arithmetic, we explicitly raise SIGFPE.
We also remove `faulthandler._read_null()` since reading from NULL is an undefined
behavior and `faulthandler` should not check for low-level C undefined behaviors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants