Skip to content

Conversation

@ankith26
Copy link
Member

@ankith26 ankith26 commented Jun 9, 2025

fixes #767
closes #766

In the first commit I added a --sanitize flag to dev.py to make it more convenient to enable sanitizers. While I was at it I also made editable rebuilds verbose by default (though one can still disable it with a --quiet flag now).

In the second commit I fixed all UBSAN issues and also added it to our CI. ASAN however catches too many issues and many of them seem to be from python, SDL and other dependencies of ours. So I don't think adding it to CI is feasible at all. However it would still be supported from dev.py incase one wants to go over the wall of errors and filter pygame-ce specific issues xD

@ankith26 ankith26 requested a review from a team as a code owner June 9, 2025 18:43
@ankith26 ankith26 force-pushed the ankith26-sanitizers branch from 60cb872 to 333f3bb Compare June 9, 2025 18:47
Copy link
Member

@oddbookworm oddbookworm left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉
Spring cleaning time (in June)

Copy link
Contributor

@gresm gresm left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ankith26 ankith26 added this to the 2.5.6 milestone Jun 10, 2025
@ankith26 ankith26 merged commit 29e821d into main Jun 10, 2025
26 checks passed
@ankith26 ankith26 deleted the ankith26-sanitizers branch June 10, 2025 08:11
Copy link
Contributor

@gresm gresm left a comment

Choose a reason for hiding this comment

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

While it's good as it is, I propose a slightly different scheme for --sanitize argument to allow mixing more modes.

Comment on lines +385 to +398
build_parser.add_argument(
"--sanitize",
choices=[
"address",
"undefined",
"address,undefined",
"leak",
"thread",
"memory",
"none",
],
default="none",
help="Enable compiler sanitizers. Defaults to 'none'.",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
build_parser.add_argument(
"--sanitize",
choices=[
"address",
"undefined",
"address,undefined",
"leak",
"thread",
"memory",
"none",
],
default="none",
help="Enable compiler sanitizers. Defaults to 'none'.",
)
build_parser.add_argument(
"--sanitize",
choices=[
"address",
"undefined",
"leak",
"thread",
"memory",
"none",
],
action="append",
help="Enable compiler sanitizers. Defaults to 'none'.",
)

Copy link
Member Author

Choose a reason for hiding this comment

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

Arbitrary choices cannot be mixed. Meson errors if you try to do that. The only mix that is allowed is address,undefined. Hence I have gone with this approach.

install_args.extend(COVERAGE_ARGS)

if sanitize:
install_args.append(f"-Csetup-args=-Db_sanitize={sanitize}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
install_args.append(f"-Csetup-args=-Db_sanitize={sanitize}")
parsed_sanitize = ",".join(sanitize) if sanitize else "none"
install_args.append(f"-Csetup-args=-Db_sanitize={parsed_sanitize}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undefined behaviour tests ubsan (1313) Address sanitizer build (1312)

4 participants