dtrace: debug abort importing module with lone surrogate unicode char in name while DTrace import probe is active
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Crash report
What happened?
This one is a bit niche! It also needs a python compiled with --with-dtrace
probe.d:
python$target:::import-find-load-start
{
printf("import probe fired\n");
}
test.py:
try:
__import__('\ud800')
except:
pass
> sudo dtrace -q -s probe.d -c './python.exe test.py'
Assertion failed: (!_PyErr_Occurred(tstate)), function _PyEval_EvalFrameDefault, file generated_cases.c.h, line 13858.
import probe fired
import probe fired
import probe fired
...
The import dtrace hooks pass call PyUnicode_AsUTF8 and pass the value to the probe without checking if the conversion succeeded, now dtrace doesn't seem to mind getting a null pointer (I don't know much about how that bit works tbh), but a stale exception is left around which triggers a debug assert:
[!CAUTION]
EDIT: I found some more cases of drace code doing the same, This isn't just limited to import machinery:
https://github.com/python/cpython/blob/91d71dd67074d4599b6bd49cc933f41f8bd57058/Python/ceval.c#L1198-L1225
If I find more, I'll add them
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Output from running 'python -VV' on the command line:
Python 3.16.0a0 (heads/main:e8158d1a02d, Aug 20 2026, 15:09:24) [Clang 21.0.0 (clang-2100.3.27.1)]
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Baue Python mit --with-dtrace und reproduziere die Assertion anhand der Beispiele probe.d und test.py. Untersuche die Import-Hooks in Python/import.c und den zusätzlichen DTrace-Code in Python/ceval.c einschließlich der verknüpften Stellen. Erledigt ist die Aufgabe, wenn der Import eines einzelnen Surrogats keine veraltete Exception mehr hinterlässt und die Debug-Assertion nicht mehr auslöst, während das Probe aktiv ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- observability
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 50/100