KEMBAR78
gh-133157: remove usage of `_Py_NO_SANITIZE_UNDEFINED` in `pyexpat` by encukou · Pull Request #135346 · python/cpython · GitHub
Skip to content

Conversation

@encukou
Copy link
Member

@encukou encukou commented Jun 10, 2025

AFAIK, to avoid undefined behavior, a function needs to be called via a function pointer of the correct type.

For storage, it can be cast to any other function type. It just needs to be cast back, when retrieved.

So, we should be able to avoid the union in #134050... but not C function for each setter (or at least one for each type, but SETTER_WRAPPER seems clearer).

@picnixz: I didn't test this all the way; will continue tomorrow

encukou and others added 2 commits June 10, 2025 15:01
…pat`

Co-Authored-By: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@picnixz
Copy link
Member

picnixz commented Jun 10, 2025

I think it's a clean alternative and doesn't need C11 (though I'm not entirely sure my solution needs C11). At least, your solution doesn't.

encukou and others added 3 commits June 11, 2025 08:30
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…85f.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@encukou encukou merged commit 845263a into python:main Jul 1, 2025
40 checks passed
@encukou encukou deleted the fix/ubsan/expat-133157 branch July 1, 2025 08:54
AndPuQing pushed a commit to AndPuQing/cpython that referenced this pull request Jul 11, 2025
…pat` (python#135346)

This was the last usage, so the macro is removed as well.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
…pat` (python#135346)

This was the last usage, so the macro is removed as well.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
picnixz added a commit to picnixz/cpython that referenced this pull request Jul 13, 2025
…pat` (python#135346)

This was the last usage, so the macro is removed as well.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
…pat` (python#135346)

This was the last usage, so the macro is removed as well.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
…pat` (python#135346)

This was the last usage, so the macro is removed as well.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
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.

2 participants