You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segmentation fault after deleting __fields__ attribute from ast.AST #126105
Python 3.14.0a1+ (heads/main:19e93e2e269, Oct 28 2024, 11:42:01) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> del ast.AST._fields
>>> t = ast.AST(arg1=123)
[1] 85885 segmentation fault ./python.exe
Py_TPFLAGS_IMMUTABLETYPE
I think that this is an overkill and it change the semantics here. We can just modify the code and check for NULL explicitly.
cc @Eclips4@JelleZijlstra (Would adding Py_TPFLAGS_IMMUTABLETYPE work or is it too restrictive?)
If you are talking about making nodes immutable, we can't do that because a lot of code relies on the fact that nodes are mutable. So it would be a huge breaking change.
Activity
picnixz commentedon Oct 29, 2024
cc @Eclips4 @JelleZijlstra (Would adding
Py_TPFLAGS_IMMUTABLETYPEwork or is it too restrictive?)sobolevn commentedon Oct 29, 2024
I can confirm, that this still happens on
main:I think that this is an overkill and it change the semantics here. We can just modify the code and check for
NULLexplicitly.See
cpython/Parser/asdl_c.py
Line 877 in 9b14083
picnixz commentedon Oct 29, 2024
Oh yes, we only need to modify:
with a NULL check beforehand I think. What do you think?
pythongh-126105: Fix crash in `ast` module, when `._fields` is deleted
pythongh-126105: Fix crash in `ast` module, when `._fields` is deleted
Eclips4 commentedon Oct 29, 2024
If you are talking about making nodes immutable, we can't do that because a lot of code relies on the fact that nodes are mutable. So it would be a huge breaking change.
gh-126105: Fix crash in `ast` module, when `._fields` is deleted (#12…
pythongh-126105: Fix crash in `ast` module, when `._fields` is deleted (
[3.12] pythongh-126105: Fix crash in `ast` module, when `._fields` is…
[3.13] gh-126105: Fix crash in `ast` module, when `._fields` is delet…
[3.12] gh-126105: Fix crash in `ast` module, when `._fields` is delet… (
Eclips4 commentedon Oct 29, 2024
Thank you Valery for the report and Nikita for the fix.
pythongh-126105: Fix crash in `ast` module, when `._fields` is deleted (
pythongh-126105: Fix crash in `ast` module, when `._fields` is deleted (