Skip to content

Attempts to catch_unwind (on Linux) result in SIGABRT #2102

Open
@stuhood

Description

@stuhood

Bug Description

Some code within a pyfunction is panicing, but rather than this resulting in a PyException via #797, it leads to a SIGABRT.

A related issue was previously reported here: pantsbuild/pants#13526 (comment) ... the fix for #1990 probably removed a panic, but other panics still seem to trigger the SIGABRT.

Steps to Reproduce

Unfortunately, the triggering panic is non-deterministic, and seemingly only occurs on Linux. Directly triggering a panic within the relevant pyfunction, properly results in a pyo3_runtime.PanicException. I'll try to report back with more information and a repro. See pantsbuild/pants#12831 (comment).

Backtrace

[Current thread is 1 (Thread 0x7fe99a924640 (LWP 3724751))]
(gdb) backtrace
#0  raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  <signal handler called>
#2  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#3  0x00007fe99fb64864 in __GI_abort () at abort.c:79
#4  0x00007fe99fbc749c in __libc_message (action=do_abort, fmt=0x7fe99fcec792 "%s", fmt=0x7fe99fcec792 "%s", action=do_abort) at ../sysdeps/posix/libc_fatal.c:155
#5  0x00007fe99fbc77b0 in __GI___libc_fatal (message=message@entry=0x7fe99fe9c118 "FATAL: exception not rethrown\n") at ../sysdeps/posix/libc_fatal.c:164
#6  0x00007fe99fe96cf6 in unwind_cleanup (reason=<optimized out>, exc=<optimized out>) at unwind.c:115
#7  0x00007fe99e77730f in panic_unwind::real_imp::cleanup () at library/panic_unwind/src/gcc.rs:78
#8  panic_unwind::__rust_panic_cleanup () at library/panic_unwind/src/lib.rs:97
#9  0x00007fe99de1873d in std::panicking::try::cleanup () at library/std/src/panicking.rs:384
#10 0x00007fe99dfe449e in std::panicking::try::do_catch<pyo3::callback::handle_panic::{closure#0}, core::result::Result<*mut pyo3::ffi::object::PyObject, pyo3::err::PyErr>> (payload=0x7fe99a924cb0, 
    data=<optimized out>) at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:428
#11 std::panicking::try<core::result::Result<*mut pyo3::ffi::object::PyObject, pyo3::err::PyErr>, pyo3::callback::handle_panic::{closure#0}> (f=...)
    at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:367
#12 std::panic::catch_unwind<pyo3::callback::handle_panic::{closure#0}, core::result::Result<*mut pyo3::ffi::object::PyObject, pyo3::err::PyErr>> (f=...)
    at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:133
#13 pyo3::callback::handle_panic<engine::externs::interface::__pyo3_raw_session_poll_workunits::{closure#0}, *mut pyo3::ffi::object::PyObject> (body=...)
    at /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.15.1/src/callback.rs:245
#14 engine::externs::interface::__pyo3_raw_session_poll_workunits (_slf=<optimized out>, _args=<optimized out>, _nargs=<optimized out>, _kwnames=<optimized out>) at src/externs/interface.rs:824
#15 0x000055f92471d38e in cfunction_vectorcall_FASTCALL_KEYWORDS (func=<built-in method session_poll_workunits of module object at remote 0x7fe99eb834f0>, args=0x7fa661bee390, nargsf=<optimized out>, 
    kwnames=<optimized out>) at Objects/methodobject.c:446
#16 0x000055f92455ea39 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x7fa661bee390, 
    callable=<built-in method session_poll_workunits of module object at remote 0x7fe99eb834f0>, tstate=0x55f92fd065f0) at ./Include/cpython/abstract.h:118
#17 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x7fa661bee390, callable=<built-in method session_poll_workunits of module object at remote 0x7fe99eb834f0>)
    at ./Include/cpython/abstract.h:127
#18 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, tstate=<optimized out>) at Python/ceval.c:5075
#19 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3487
#20 0x000055f924556e9b in _PyEval_EvalFrame (throwflag=0, 
    f=Frame 0x7fa661bee200, for file $HOME/.cache/pants/setup/bootstrap-Linux-x86_64/2.9.0_py39/lib/python3.9/site-packages/pants/engine/internals/scheduler.py, line 618, in poll_workunits (self=<SchedulerSession(_scheduler=<Scheduler(include_trace_on_error=True, _visualize_to_dir=None, _visualize_run_count=0, _py_scheduler=<builtins.PyScheduler at remote 0x7fa661bd45f0>) at remote 0x7fe99c2b25e0>, _py_session=<builtins.PySession at remote 0x7fe9980a82a0>) at remote 0x7fa661ca8d30>, max_log_verbosity=<LogLevel(_value_='trace', _level=5, _name_='TRACE', __objclass__=<EnumMeta(_generate_next_value_=<function at remote 0x7fe99f36e700>, __module__='pants.util.logging', __annotations__={'_level': 'int'}, __new__=<function at remote 0x7fe99f36e670>, level=<property at remote 0x7fe99d784400>, log=<function at remote 0x7fe99d77a790>, set_level_for=<function at remote 0x7fe99d77a820>, __doc__='An enumeration.', _member_names_=['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR'], _member_map_={'TRACE': <...>, 'DEBUG': <LogLe...(truncated), tstate=0x55f92fd065f0) at ./Include/internal/pycore_ceval.h:40
#21 function_code_fastcall (tstate=0x55f92fd065f0, co=<optimized out>, args=<optimized out>, nargs=2, globals=<optimized out>) at Objects/call.c:330
#22 0x000055f92455e194 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x7fa661bec950, callable=<function at remote 0x7fe99d20d670>, tstate=0x55f92fd065f0)
    at ./Include/cpython/abstract.h:118
#23 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x7fa661bec950, callable=<function at remote 0x7fe99d20d670>) at ./Include/cpython/abstract.h:127
#24 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, tstate=<optimized out>) at Python/ceval.c:5075
#25 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3504
#26 0x000055f92461fb4a in _PyEval_EvalFrame (throwflag=0, 
    f=Frame 0x7fa661bec7c0, for file $HOME/.cache/pants/setup/bootstrap-Linux-x86_64/2.9.0_py39/lib/python3.9/site-packages/pants/engine/streaming_workunit_handler.py, line 250, in poll_workunits (self=<_InnerHandler(_target=None, _name='Thread-1', _args=(), _kwargs={}, _daemonic=True, _ident=140641297385024, _native_id=3724751, _tstate_lock=<_thread.lock at remote 0x7fa661d77a50>, _started=<Event(_cond=<Condition(_lock=<_thread.lock at remote 0x7fa661c9db40>, acquire=<built-in method acquire of _thread.lock object at remote 0x7fa661c9db40>, release=<built-in method release of _thread.lock object at remote 0x7fa661c9db40>, _waiters=<collections.deque at remote 0x7fa661d07fa0>) at remote 0x7fa661c9db80>, _flag=True) at remote 0x7fa661c9dbe0>, _is_stopped=False, _initialized=True, _stderr=<builtins.PyStdioWrite at remote 0x7fe99cc24a30>, _invoke_excepthook=<function at remote 0x7fa661d1a820>, scheduler=<SchedulerSession(_scheduler=<Scheduler(include_trace_on_error=True, _visualize_to_dir=None, _visualize_run...(truncated), tstate=0x55f92fd065f0) at ./Include/internal/pycore_ceval.h:40

Your operating system and version

Ubuntu 21.04, Arch with kernel 5.13.13-arch1-1

Your Python version (python --version)

3.7, 3.9

Your Rust version (rustc --version)

1.57.0

Your PyO3 version

0.15.1

How did you install python? Did you use a virtualenv?

Inside a virtualenv, but retrieved via system-relevant package managers.

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions