Skip to content

gh-133157: remove usage of _Py_NO_SANITIZE_UNDEFINED in Parser/pegen.c#134048

Merged
pablogsal merged 3 commits into
python:mainfrom
picnixz:fix/ubsan/pegen-133157
Jun 10, 2025
Merged

gh-133157: remove usage of _Py_NO_SANITIZE_UNDEFINED in Parser/pegen.c#134048
pablogsal merged 3 commits into
python:mainfrom
picnixz:fix/ubsan/pegen-133157

Conversation

@picnixz

@picnixz picnixz commented May 15, 2025

Copy link
Copy Markdown
Member

We remove undefined behaviors by adding more "overloads" functions. I've added some small checks to detect possible future undefined behaviors.

Comment thread Tools/peg_generator/pegen/c_generator.py Outdated
@picnixz

picnixz commented Jun 9, 2025

Copy link
Copy Markdown
Member Author

@pablogsal friendly ping

@pablogsal pablogsal added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jun 10, 2025
@pablogsal

Copy link
Copy Markdown
Member

LGTM. Great work on factoring this into a macro and the check in the generator 👌

@pablogsal pablogsal merged commit 754e7c9 into python:main Jun 10, 2025
54 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @picnixz for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 10, 2025
…er/pegen.c` (pythonGH-134048)

(cherry picked from commit 754e7c9)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@miss-islington-app

Copy link
Copy Markdown

Sorry, @picnixz and @pablogsal, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 754e7c9b5187fcad22acf7555479603f173a4a09 3.13

@bedevere-app

bedevere-app Bot commented Jun 10, 2025

Copy link
Copy Markdown

GH-135320 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 10, 2025
@pablogsal

Copy link
Copy Markdown
Member

Can you do the backport to 3.13?

@picnixz

picnixz commented Jun 10, 2025

Copy link
Copy Markdown
Member Author

I'll do the backport tomorrow! (I'm going to sleep in a few minutes :'))

@picnixz picnixz self-assigned this Jun 10, 2025
pablogsal pushed a commit that referenced this pull request Jun 10, 2025
…ser/pegen.c` (GH-134048) (#135320)

gh-133157: remove usage of `_Py_NO_SANITIZE_UNDEFINED` in `Parser/pegen.c` (GH-134048)
(cherry picked from commit 754e7c9)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@picnixz picnixz deleted the fix/ubsan/pegen-133157 branch June 10, 2025 08:45
picnixz added a commit to picnixz/cpython that referenced this pull request Jun 10, 2025
…n `Parser/pegen.c` (pythonGH-134048)

(cherry picked from commit 754e7c9)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Jun 10, 2025

Copy link
Copy Markdown

GH-135334 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 10, 2025
@bedevere-app

bedevere-app Bot commented Jun 10, 2025

Copy link
Copy Markdown

GH-135334 is a backport of this pull request to the 3.13 branch.

picnixz added a commit that referenced this pull request Jun 10, 2025
…135334)

[3.13] gh-133157: fix UBSan failures in `Parser/pegen.c` (GH-134048)
(cherry picked from commit 754e7c9)
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Debian root 3.13 (tier-1) has failed when building commit dd7ffdb.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1441/builds/1259) and take a look at the build logs.
  4. Check if the failure is related to this commit (dd7ffdb) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1441/builds/1259

Summary of the results of the build (if available):

Click to see traceback logs
remote: Enumerating objects: 10, done.        
remote: Counting objects:  10% (1/10)        
remote: Counting objects:  20% (2/10)        
remote: Counting objects:  30% (3/10)        
remote: Counting objects:  40% (4/10)        
remote: Counting objects:  50% (5/10)        
remote: Counting objects:  60% (6/10)        
remote: Counting objects:  70% (7/10)        
remote: Counting objects:  80% (8/10)        
remote: Counting objects:  90% (9/10)        
remote: Counting objects: 100% (10/10)        
remote: Counting objects: 100% (10/10), done.        
remote: Total 10 (delta 9), reused 9 (delta 9), pack-reused 0 (from 0)        
From https://github.com/python/cpython
 * branch                    3.13       -> FETCH_HEAD
Note: switching to 'dd7ffdbbff35d9a86906c71ee2c15a1cee02701d'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at dd7ffdbbff3 [3.13] gh-133157: fix UBSan failures in `Parser/pegen.c` (GH-134048) (#135334)
Switched to and reset branch '3.13'

configure: WARNING: no system libmpdecimal found; falling back to bundled libmpdecimal (deprecated and scheduled for removal in Python 3.15)
configure: WARNING: pkg-config is missing. Some dependencies may not be detected correctly.

make: *** wait: No child processes.  Stop.
make: *** Waiting for unfinished jobs....
make: *** wait: No child processes.  Stop.

Cannot open file '/root/buildarea/3.13.angelico-debian-amd64/build/test-results.xml' for upload

lkollar pushed a commit to lkollar/cpython that referenced this pull request Jun 19, 2025
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants