Skip to content

'SystemError: Type does not define the tp_name field' when an unhandled exception is thrown in an async function #174

@WhiteAbeLincoln

Description

@WhiteAbeLincoln

componentize-py version: 0.18.0
reproduction: https://github.com/WhiteAbeLincoln/tp_name_reproduction

I'm noticing this error if an exception is raised from within an async function. It did not occur under 0.17.2.
The error raised is:

(nix:nix-shell-env) bash-5.3$ ./run.sh
Building wasm component...
warning: site-packages directory not found under /Users/abe/Projects/tp_name_reproduction/test/.venv/lib
Component built successfully
Executing wasm component...
error: Type does not define the tp_name field.
Traceback (most recent call last):
  File "/python/asyncio/runners.py", line 204, in run
  File "/python/asyncio/runners.py", line 127, in run
  File "/python/asyncio/base_events.py", line 719, in run_until_complete
  File "/0/test/__init__.py", line 13, in maybe_crash
Exception: Intentional exception to test cleanup

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/0/test/__init__.py", line 26, in run
  File "/python/asyncio/runners.py", line 203, in run
  File "/python/asyncio/runners.py", line 63, in __exit__
SystemError: Type does not define the tp_name field.

This causes the wasmtime cli to never exit. I'm not sure if that's by design on their part because my custom embedding
crashed after running into this error.

The reproduction is very simple - just throw an error within an async function which is running using asyncio.run.

I got an extended backtrace from the embedding which seems to point at an error when
deallocating the exception, but I don't know whether that's the root cause:

Exception in workflow_main: Type does not define the tp_name field.
Traceback (most recent call last):
  File "/1/m2i_workflow_sdk/entry.py", line 105, in main
  File "/python/asyncio/runners.py", line 127, in run
  File "/python/asyncio/base_events.py", line 719, in run_until_complete
  File "/0/tcp.py", line 60, in workflow_main
Exception: Intentional exception to test cleanup

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/1/m2i_workflow_sdk/entry.py", line 104, in main
File "/python/asyncio/runners.py", line 63, in exit
SystemError: Type does not define the tp_name field.

Error: workflow should complete

Caused by:
0: failed to run wasm module: error while executing at wasm backtrace:
0: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
1: 0xe4114d - Py_DECREF_MORTAL
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_object.h:482:9
- PyStackRef_XCLOSE
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_stackref.h:660:9
- frame_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/frameobject.c:1937:13
2: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
3: 0x1034815 - Py_DECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:419:9
- Py_XDECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:512:9
- tb_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/traceback.c:240:5
4: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
5: 0x10347e0 - Py_DECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:419:9
- Py_XDECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:512:9
- tb_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/traceback.c:239:5
6: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
7: 0xe2ac6a - Py_DECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:419:9
- BaseException_clear
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/exceptions.c:139:5
8: 0xe2ebac - BaseException_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/exceptions.c:153:11
9: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
10: 0xe2ace2 - Py_DECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:419:9
- BaseException_clear
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/exceptions.c:141:5
11: 0xe2ebac - BaseException_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/exceptions.c:153:11
12: 0xea885a - subtype_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/typeobject.c:2708:5
13: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
14: 0xe7e6d8 - Py_DECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:419:9
- _Py_DecRef
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:354:5
15: 0x13f6b - !<wasm function 303>
16: 0xc61202 - libcomponentize_py_runtime.so!pyo3::internal::state::register_decref::h10509524002982b7
17: 0xc37999 - libcomponentize_py_runtime.so!componentize-py#Dispatch
18: 0x2794cca - libcomponentize_py_bindings.so!m2i:workflows/workflow@0.1.0#main-export
1: error while executing at wasm backtrace:
0: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
1: 0xe4114d - Py_DECREF_MORTAL
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_object.h:482:9
- PyStackRef_XCLOSE
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_stackref.h:660:9
- frame_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/frameobject.c:1937:13
2: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
3: 0x1034815 - Py_DECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:419:9
- Py_XDECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:512:9
- tb_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/traceback.c:240:5
4: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
5: 0x10347e0 - Py_DECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:419:9
- Py_XDECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:512:9
- tb_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/traceback.c:239:5
6: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
7: 0xe2ac6a - Py_DECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:419:9
- BaseException_clear
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/exceptions.c:139:5
8: 0xe2ebac - BaseException_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/exceptions.c:153:11
9: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
10: 0xe2ace2 - Py_DECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:419:9
- BaseException_clear
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/exceptions.c:141:5
11: 0xe2ebac - BaseException_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/exceptions.c:153:11
12: 0xea885a - subtype_dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/typeobject.c:2708:5
13: 0xe7e5c5 - _Py_Dealloc
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:3072:5
14: 0xe7e6d8 - Py_DECREF
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/refcount.h:419:9
- _Py_DecRef
at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/object.c:354:5
15: 0x13f6b - !<wasm function 303>
16: 0xc61202 - libcomponentize_py_runtime.so!pyo3::internal::state::register_decref::h10509524002982b7
17: 0xc37999 - libcomponentize_py_runtime.so!componentize-py#Dispatch
18: 0x2794cca - libcomponentize_py_bindings.so!m2i:workflows/workflow@0.1.0#main-export
2: wasm trap: uninitialized element

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions