Skip to content

gh-133157: remove usage of _Py_NO_SANITIZE_UNDEFINED in pyexpat #135346

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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.

XML_Parser,
const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);

#define SETTER_WRAPPER(NAME, TYPE) \
Copy link
Member

Choose a reason for hiding this comment

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

Maybe call it XML_SETTER_WRAPPER?

Copy link
Member Author

Choose a reason for hiding this comment

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

In a local macro in this file, I don't think it's necessary.

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