PY_SSIZE_T_MIN negate UB in unicode_format.c and bytesobject.c
Open
Nobody has claimed this yet.
interpreter-core
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
Original gist: https://gist.github.com/devdanzin/577421b083bad6802aa391b909d1a725
unicode_format_arg_parse (line 563): -PY_SSIZE_T_MIN is undefined behavior in C. Benign on two's-complement but technically UB. bytesobjects.c have the same problem.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-151849
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading unicode_format_arg_parse in unicode_format.c and the corresponding code in bytesobject.c, then inspect existing tests covering formatting. Done means both reported PY_SSIZE_T_MIN negations are addressed without undefined behavior and the relevant CPython tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100