GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — SystemError: <method-wrapper '__init__' of ast.AST-child object at ...> returned NULL without setting an exception · Issue #117266 · python/cpython

SystemError: <method-wrapper '__init__' of ast.AST-child object at ...> returned NULL without setting an exception #117266

New issue
Copy link
New issue
Copy link
Closed
Closed
SystemError: <method-wrapper '__init__' of ast.AST-child object at ...> returned NULL without setting an exception#117266
Copy link
Assignees
JelleZijlstra
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@hroncok
hroncok
opened on Mar 26, 2024
Issue body actions

Bug report

Bug description:

import ast


class File(ast.AST):
    _fields = ("xxx",)

    def __init__(self):
        super().__init__()


File()
Traceback (most recent call last):
  File ".../method_wrapper.py", line 11, in <module>
    File()
    ~~~~^^
  File ".../method_wrapper.py", line 8, in __init__
    super().__init__()
    ~~~~~~~~~~~~~~~~^^
SystemError: <method-wrapper '__init__' of File object at 0x7f923918cf10> returned NULL without setting an exception

This has happened since 3.13.0a5. Discovered via real usage in robotframework/robotframework#5091

CPython versions tested on:

3.13, CPython main branch

Operating systems tested on:

Linux

Linked PRs

  • gh-117266: Fix crashes on user-created AST subclasses #117276
Reacted by Pekka Klärck

Activity

  1. hroncok
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Mar 26, 2024
  2. hroncok commented on Mar 26, 2024

    @hroncok
    hroncok
    on Mar 26, 2024
    ContributorAuthor
    More actions

    Possibly started with ed4dfd8

  3. hroncok commented on Mar 26, 2024

    @hroncok
    hroncok
    on Mar 26, 2024
    ContributorAuthor
    More actions

    Indeed, git bisect confirms this started with ed4dfd8.

  4. hroncok commented on Mar 26, 2024

    @hroncok
    hroncok
    on Mar 26, 2024
    ContributorAuthor
    More actions

    Using the debug build:

    $ ./python -X dev  ~/tmp/method_wrapper.py
    Fatal Python error: _Py_CheckFunctionResult: a function returned NULL without setting an exception
    Python runtime state: initialized
    SystemError: <method-wrapper '__init__' of File object at 0x7f50527c15a0> returned NULL without setting an exception
    
    Current thread 0x00007f505ff43740 (most recent call first):
      File ".../method_wrapper.py", line 8 in __init__
      File ".../method_wrapper.py", line 11 in <module>
    Aborted (core dumped)
    
    
  5. hroncok commented on Mar 26, 2024

    @hroncok
    hroncok
    on Mar 26, 2024
    ContributorAuthor
    More actions
    (gdb) bt
    #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0)
        at pthread_kill.c:44
    #1  0x00007ffff7d6e8a3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
    #2  0x00007ffff7d1c8ee in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
    #3  0x00007ffff7d048ff in __GI_abort () at abort.c:79
    #4  0x00000000006270ee in fatal_error_exit (status=<optimized out>) at Python/pylifecycle.c:2817
    #5  0x00000000006287d2 in fatal_error (fd=2, header=header@entry=1, 
        prefix=prefix@entry=0x6d5590 <__func__.23> "_Py_CheckFunctionResult", 
        msg=msg@entry=0x6d4fc8 "a function returned NULL without setting an exception", status=status@entry=-1)
        at Python/pylifecycle.c:2998
    #6  0x000000000062883c in _Py_FatalErrorFunc (func=func@entry=0x6d5590 <__func__.23> "_Py_CheckFunctionResult", 
        msg=msg@entry=0x6d4fc8 "a function returned NULL without setting an exception") at Python/pylifecycle.c:3014
    #7  0x00000000004aeaf3 in _Py_CheckFunctionResult (tstate=tstate@entry=0x946250 <_PyRuntime+247824>, 
        callable=callable@entry=0x7fffea4dd450, result=result@entry=0x0, where=where@entry=0x0) at Objects/call.c:43
    #8  0x00000000004aef04 in _PyObject_MakeTpCall (tstate=tstate@entry=0x946250 <_PyRuntime+247824>, 
        callable=callable@entry=0x7fffea4dd450, args=args@entry=0x7ffff7fb80f8, nargs=<optimized out>, 
        keywords=keywords@entry=0x0) at Objects/call.c:252
    #9  0x00000000004aefe5 in _PyObject_VectorcallTstate (tstate=0x946250 <_PyRuntime+247824>, 
        callable=callable@entry=0x7fffea4dd450, args=args@entry=0x7ffff7fb80f8, nargsf=<optimized out>, 
        kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:166
    #10 0x00000000004af033 in PyObject_Vectorcall (callable=callable@entry=0x7fffea4dd450, 
        args=args@entry=0x7ffff7fb80f8, nargsf=<optimized out>, kwnames=kwnames@entry=0x0) at Objects/call.c:327
    #11 0x00000000005b3cf5 in _PyEval_EvalFrameDefault (tstate=0x946250 <_PyRuntime+247824>, frame=0x7ffff7fb8090, 
        throwflag=0) at Python/generated_cases.c.h:817
    #12 0x00000000005cb33e in _PyEval_EvalFrame (tstate=tstate@entry=0x946250 <_PyRuntime+247824>, 
        frame=<optimized out>, throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:114
    #13 0x00000000005cb451 in _PyEval_Vector (tstate=0x946250 <_PyRuntime+247824>, func=0x7fffea4d56d0, 
        locals=locals@entry=0x0, args=0x7fffffffcdf0, argcount=1, kwnames=0x0) at Python/ceval.c:1820
    #14 0x00000000004aec45 in _PyFunction_Vectorcall (func=<optimized out>, stack=<optimized out>, 
        nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:413
    #15 0x00000000004b01be in _PyObject_VectorcallDictTstate (tstate=tstate@entry=0x946250 <_PyRuntime+247824>, 
        callable=callable@entry=0x7fffea4d56d0, args=args@entry=0x7fffffffcdf0, nargsf=nargsf@entry=1, 
        kwargs=kwargs@entry=0x0) at Objects/call.c:135
    #16 0x00000000004b0370 in _PyObject_Call_Prepend (tstate=tstate@entry=0x946250 <_PyRuntime+247824>, 
        callable=callable@entry=0x7fffea4d56d0, obj=obj@entry=0x7fffea4dd500, 
        args=args@entry=0x920b10 <_PyRuntime+94416>, kwargs=kwargs@entry=0x0) at Objects/call.c:504
    #17 0x000000000052de1a in slot_tp_init (self=0x7fffea4dd500, args=0x920b10 <_PyRuntime+94416>, kwds=0x0)
        at Objects/typeobject.c:9355
    #18 0x00000000005294f3 in type_call (self=self@entry=0xab6130, args=args@entry=0x920b10 <_PyRuntime+94416>, 
        kwds=kwds@entry=0x0) at Objects/typeobject.c:1789
    #19 0x00000000004aedd2 in _PyObject_MakeTpCall (tstate=tstate@entry=0x946250 <_PyRuntime+247824>, 
        callable=callable@entry=0xab6130, args=args@entry=0x7ffff7fb8078, nargs=<optimized out>, 
        keywords=keywords@entry=0x0) at Objects/call.c:242
    #20 0x00000000004aefe5 in _PyObject_VectorcallTstate (tstate=0x946250 <_PyRuntime+247824>, 
        callable=callable@entry=0xab6130, args=args@entry=0x7ffff7fb8078, nargsf=<optimized out>, 
        kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:166
    #21 0x00000000004af033 in PyObject_Vectorcall (callable=callable@entry=0xab6130, 
        args=args@entry=0x7ffff7fb8078, nargsf=<optimized out>, kwnames=kwnames@entry=0x0) at Objects/call.c:327
    #22 0x00000000005b3cf5 in _PyEval_EvalFrameDefault (tstate=0x946250 <_PyRuntime+247824>, frame=0x7ffff7fb8020, 
        throwflag=0) at Python/generated_cases.c.h:817
    #23 0x00000000005cb33e in _PyEval_EvalFrame (tstate=tstate@entry=0x946250 <_PyRuntime+247824>, 
        frame=<optimized out>, throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:114
    #24 0x00000000005cb451 in _PyEval_Vector (tstate=tstate@entry=0x946250 <_PyRuntime+247824>, 
        func=func@entry=0x7fffea469cd0, locals=locals@entry=0x7fffea4813d0, args=args@entry=0x0, 
        argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:1820
    #25 0x00000000005cb501 in PyEval_EvalCode (co=co@entry=0x7fffea5a25c0, globals=globals@entry=0x7fffea4813d0, 
        locals=locals@entry=0x7fffea4813d0) at Python/ceval.c:599
    #26 0x000000000062d406 in run_eval_code_obj (tstate=tstate@entry=0x946250 <_PyRuntime+247824>, 
        co=co@entry=0x7fffea5a25c0, globals=globals@entry=0x7fffea4813d0, locals=locals@entry=0x7fffea4813d0) at Python/pythonrun.c:1291
    #27 0x000000000062d5bb in run_mod (mod=mod@entry=0xa90ee0, filename=filename@entry=0x7fffea4cd850, 
        globals=globals@entry=0x7fffea4813d0, locals=locals@entry=0x7fffea4813d0, flags=flags@entry=0x7fffffffd3e8, 
        arena=arena@entry=0x7fffea4cab60, interactive_src=0x0, generate_new_source=0) at Python/pythonrun.c:1376
    #28 0x000000000062dcfd in pyrun_file (fp=fp@entry=0xa29aa0, filename=filename@entry=0x7fffea4cd850, 
        start=start@entry=257, globals=globals@entry=0x7fffea4813d0, locals=locals@entry=0x7fffea4813d0, 
        closeit=closeit@entry=1, flags=0x7fffffffd3e8) at Python/pythonrun.c:1212
    #29 0x000000000062f32e in _PyRun_SimpleFileObject (fp=fp@entry=0xa29aa0, 
        filename=filename@entry=0x7fffea4cd850, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffd3e8)
        at Python/pythonrun.c:461
    #30 0x000000000062f50e in _PyRun_AnyFileObject (fp=fp@entry=0xa29aa0, filename=filename@entry=0x7fffea4cd850, 
        closeit=closeit@entry=1, flags=flags@entry=0x7fffffffd3e8) at Python/pythonrun.c:77
    #31 0x0000000000650d3c in pymain_run_file_obj (program_name=program_name@entry=0x7fffea4a2c40, 
        filename=filename@entry=0x7fffea4cd850, skip_source_first_line=0) at Modules/main.c:357
    #32 0x0000000000650e48 in pymain_run_file (config=config@entry=0x921178 <_PyRuntime+96056>)
        at Modules/main.c:376
    #33 0x000000000065160e in pymain_run_python (exitcode=exitcode@entry=0x7fffffffd54c) at Modules/main.c:628
    #34 0x0000000000651836 in Py_RunMain () at Modules/main.c:707
    #35 0x000000000065188a in pymain_main (args=args@entry=0x7fffffffd590) at Modules/main.c:737
    #36 0x000000000065190a in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:761
    #37 0x000000000041d84f in main (argc=<optimized out>, argv=<optimized out>) at ./Programs/python.c:15
    
  6. JelleZijlstra
    self-assigned this
    on Mar 26, 2024
  7. JelleZijlstra commented on Mar 26, 2024

    @JelleZijlstra
    JelleZijlstra
    on Mar 26, 2024
    Member
    More actions

    Thanks! I'll look into it.

    Reacted by Miro Hrončok
  8. JelleZijlstra commented on Mar 27, 2024

    @JelleZijlstra
    JelleZijlstra
    on Mar 27, 2024
    Member
    More actions

    Fix in #117276. I'll add the "release-blocker" label because this is a regression and should be fixed before the next alpha.

  9. JelleZijlstra
    added
    release-blocker
    on Mar 27, 2024
  10. ezio-melotti
    added this to Release and Deferred blockers 🚫on Mar 27, 2024
  11. github-project-automation
    moved this to Todo in Release and Deferred blockers 🚫on Mar 27, 2024
  12. encukou
    added a commit that references this issue on Mar 28, 2024

    gh-117266: Fix crashes on user-created AST subclasses (GH-117276)

    4c71d51
  13. encukou commented on Mar 28, 2024

    @encukou
    encukou
    on Mar 28, 2024
    Member
    More actions

    Thanks for the fix. Since it's a blocker I merged it, even though I'd have one more review comment:

    It would be good to add this to the new test, and improve the behaviour (the error is quite opaque):

            class MoreFieldsThanTypes(ast.AST):
                _fields = ('a', 'b')
                _field_types = {'a': int | None}
                a: int | None = None
                b: int | None = None
  14. encukou
    removed
    release-blocker
    on Mar 28, 2024
  15. NGRsoftlab
    added 2 commits that reference this issue on Apr 2, 2024

    Squashed commit of the following:

    1b5fe4c

    Squashed commit of the following:

    a016a54
  16. diegorusso
    added a commit that references this issue on Apr 17, 2024

    pythongh-117266: Fix crashes on user-created AST subclasses (pythonGH…

    70138e4
  17. JelleZijlstra commented on May 24, 2024

    @JelleZijlstra
    JelleZijlstra
    on May 24, 2024
    Member
    More actions

    #118212 further improved the situation; I don't think there's anything left to do.

  18. JelleZijlstra
    closed this as completedon May 24, 2024
  19. github-project-automation
    moved this from Todo to Done in Release and Deferred blockers 🚫on May 24, 2024
  20. hroncok commented on May 24, 2024

    @hroncok
    hroncok
    on May 24, 2024
    ContributorAuthor
    More actions

    Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @JelleZijlstra
    JelleZijlstra

Labels

type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

  • Release and Deferred blockers 🚫
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.