python / python/cpython

`unsafe_{latin,long,float}_compare` have an `assert` that assumes `PyObject_RichCompareBool` can't fail

Open
#148,268 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

easy interpreter-core type-crash
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Crash report

What happened?

Added in https://github.com/python/cpython/commit/1e34da49ef22004ca25c517b3f07c6d25f083ece, we assert that:
https://github.com/python/cpython/blob/eab7dbda3b7502f0a952901a80fb5e628ccd7a28/Objects/listobject.c#L2858

However, PyObject_RichCompareBool can fail and return -1 on error, triggering the assert.

Found by OSS Fuzz in #444686879.

CC @rhettinger and @tim-one

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Output from running 'python -VV' on the command line:

No response

Linked PRs
  • gh-148309
  • gh-151820

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Objects/listobject.c at the unsafe_{latin,long,float}_compare assert and review the PyObject_RichCompareBool call documented in the report. Reproduce or inspect the OSS-Fuzz case from #444686879, then verify the relevant behavior no longer triggers an assertion when comparison returns an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.