Skip to content

PYTHON-6048 Add address and undefined behavior sanitizer tests - #39

Open
blink1073 wants to merge 11 commits into
mainfrom
asan-PYTHON-6048
Open

blink1073 wants to merge 11 commits into
mainfrom
asan-PYTHON-6048

Conversation

@blink1073

Copy link
Copy Markdown
Owner

PYTHON-6048 / PYTHON-6252 Add ASan/UBSan sanitizer tests and fix C buffer growth overflow

Changes in this PR

The C extensions never run under sanitizers, so memory errors and undefined behavior in the hand-written C code can pass every test. This adds an Evergreen suite that builds them against the toolchain's ASan/UBSan-instrumented CPython and runs the BSON and client tests under it. The task fails if the C extension does not build or UBSan reports undefined behavior:

  • Adds a pr-tagged sanitizer-rhel8 variant, so the suite runs on every pull request.
  • Fixes signed-integer-overflow UB in the C encoder's buffer doubling past 1GiB (residual from the PYTHON-5996 hardening): growth past the doubling bound now goes to exactly the requested size, without computing the overflow (PYTHON-6252).
  • Documents the suite in CONTRIBUTING.md.

No public or private API changes: the encoder fix preserves behavior, and the rest is Evergreen configuration, tests, and contributor docs.

Test Plan

  • The sanitizer job surfaced the buffer-growth UB: UBSan (halt_on_error=1) killed the run at test_encode_size_limit with its report swallowed by pytest's output capture. Reproduced standalone, then fixed (PYTHON-6252).
  • Config-rule unit tests: 11 passed (the env wiring is verified by the patch build).
  • Local instrumented build (ASan+UBSan, halt on error): BSON suite 103 passed.
  • Full pre-commit lint green.
  • A fresh patch build on sanitizer-rhel8 validates the full task end to end.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s). PYTHON-6168, PYTHON-6169

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

This branch has not been deployed

No deployments
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.

2 participants