[Bugfix] WangSet.terrain_enum() calls Python with a pending error -> _PyErr_Occurred assertion / abort #322
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#322
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
PyWangSet::terrain_enum(src/tiled/PyWangSet.cpp:148) invokes a Python callable viaPyObject_Callwhile a Python exception is already set. In a debug CPython this trips the assertion!_PyErr_Occurred(tstate)in_PyObject_Calland aborts; in release builds it is undefined/erratic behavior (the call proceeds with a stale error pending).Found by the #312 fuzz campaign (
fuzz_import_parserstarget) feeding a malformed Tiled.tsxwangset.Crash output
Analysis
terrain_enum()builds a PythonIntEnumfrom the wangset's parsed colors. On malformed input some earlier step sets a Python error (e.g. a failed attribute/format on a corrupt color name) that is not cleared, thenterrain_enumcalls into Python again with the error still pending. The fix is to ensure no error is pending beforePyObject_Call(check/propagate orPyErr_Clearat the right boundary), or to bail out cleanly when an error is already set.Repro
Suggested labels
Bugfix,system:python-binding,priority:tier2-foundation(apply via web — MCP label bug)Related: #312, #283.