segfault/debug abort from `perf_map_write_entry` with lone surrogate in filename or qualname
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Crash report
What happened?
import sys
import sysconfig
import types
assert not sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE")
sys.activate_stack_trampoline("perf")
code = compile("pass", "bad\ud800file", "exec")
eval(code)
python3: Python/generated_cases.c.h:13862: PyObject *_PyEval_EvalFrameDefault(PyThreadState *, _PyInterpreterFrame *, int): Assertion `!_PyErr_Occurred(tstate)' failed.
Aborted
perf_map_write_entry does not check that the calls to PyUnicde_AsUTF8 succeed, resulting in null pointers being passed to snprintf. This is UB, and may crash in some libc versions, or may be replaced with a placeholder value.
Regardless, a failed conversion leaves a stale exception around, which then will trigger a debug abort a bit later (in debug builds):
Seems trivial to check the result value here. I notice that perf_jit_trampoline (similar code) uses a common helper function that checks the values and replaces them with "" if NULL
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.16.0a0 (heads/main-dirty:20e6c2f, Aug 19 2026, 15:22:30) [Clang 22.1.8 ]
Linked PRs
- gh-156300
- gh-157773
- gh-157774
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in Python/perf_trampoline.c, in perf_map_write_entry, e confronta la relativa gestione della conversione con l’helper condiviso utilizzato da perf_jit_trampoline. Riproduci la segnalazione con l’esempio del nome file contenente un lone surrogate, quindi verifica che il fallimento della conversione non lasci più un’eccezione residua né provochi un abort; i PR collegati indicano che questo lavoro è già in corso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, python
- Ambito
- operating-systems, performance
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 25/100