Skip to content

Segfault in mp_obj_exception_add_traceback #17117

@smurfix

Description

@smurfix

Port, board and/or hardware

Unix

MicroPython version

master branch with taskgroup PR #8791, commit 32608f0; at first glance this seems to be related to async-error handling (obvious from the stack trace …) but not necessarily specific to the taskgroup stuff.

Reproduction

Currently somewhat involved, as in

  • pull smurfix/moat
  • update submodules
  • go to ext/micropython/ports/unix and build with DEBUG=1 STRIP=
  • run pytest tests/micro/test_micro.py::test_iter_m
  • ulimit -c unlimited
  • probably install some bits&pieces from the requirements in pyproject.toml if that fails
  • run gdb on the resulting coredump

Expected behaviour

No crash.

I have added a very ugly workaround, see commit f7635bb in repo https://github.com/smurfix/micropython ("hack" branch) which appears to circumvent the problem with no ill effects. So far (I'm in the middle of refactoring my code rather aggressively). Not a real fix by any means but I have no idea where the error is ultimately coming from.

Observed behaviour

(gdb) fr 0
#0  0x000055a98ac3ee22 in mp_obj_exception_add_traceback (self_in=<optimized out>, file=1788,
    line=291, block=138) at ../../py/objexcept.c:636
636	   self->traceback_len += TRACEBACK_ENTRY_LEN;
(gdb) p self
$3 = (mp_obj_exception_t *) 0x55a98ace53c0 <native_base_init_wrapper_obj>
(gdb)

… which definitely isn't supposed to happen.

Additional Information

#0  0x000055a98ac3ee22 in mp_obj_exception_add_traceback (self_in=<optimized out>, file=1788,
    line=291, block=138) at ../../py/objexcept.c:636
#1  0x000055a98ac518dd in mp_execute_bytecode (code_state=code_state@entry=0x7fce5a98bf30,
    inject_exc=inject_exc@entry=0x0) at ../../py/vm.c:1434
#2  0x000055a98ac40275 in mp_obj_gen_resume (self_in=self_in@entry=0x7fce5a98bf20,
    send_value=send_value@entry=0x6, throw_value=throw_value@entry=0x0,
    ret_val=ret_val@entry=0x7ffed951d3f8) at ../../py/objgenerator.c:210
#3  0x000055a98ac36bb0 in mp_resume (self_in=0x7fce5a98bf20, send_value=0x6,
    throw_value=throw_value@entry=0x0, ret_val=ret_val@entry=0x7ffed951d3f8)
    at ../../py/runtime.c:1425
#4  0x000055a98ac53199 in mp_execute_bytecode (code_state=code_state@entry=0x7fce5a97b8d0,
    inject_exc=inject_exc@entry=0x0) at ../../py/vm.c:1203
#5  0x000055a98ac40275 in mp_obj_gen_resume (self_in=self_in@entry=0x7fce5a97b8c0,
    send_value=send_value@entry=0x6, throw_value=throw_value@entry=0x0,
    ret_val=ret_val@entry=0x7ffed951d558) at ../../py/objgenerator.c:210
#6  0x000055a98ac36bb0 in mp_resume (self_in=0x7fce5a97b8c0, send_value=0x6,
    throw_value=throw_value@entry=0x0, ret_val=ret_val@entry=0x7ffed951d558)
    at ../../py/runtime.c:1425
...
#19 0x000055a98ac53199 in mp_execute_bytecode (code_state=code_state@entry=0x7fce5a97aeb0,
    inject_exc=inject_exc@entry=0x0) at ../../py/vm.c:1203
#20 0x000055a98ac40275 in mp_obj_gen_resume (self_in=0x7fce5a97aea0,
    send_value=<optimized out>, throw_value=throw_value@entry=0x0,
    ret_val=ret_val@entry=0x7ffed951dba8) at ../../py/objgenerator.c:210
#21 0x000055a98ac40302 in gen_resume_and_raise (self_in=<optimized out>,
    send_value=<optimized out>, throw_value=throw_value@entry=0x0,
    raise_stop_iteration=raise_stop_iteration@entry=true) at ../../py/objgenerator.c:259
#22 0x000055a98ac4039c in gen_instance_send (self_in=<optimized out>,
    send_value=<optimized out>) at ../../py/objgenerator.c:286
#23 0x000055a98ac3f7ea in fun_builtin_2_call (self_in=0x55a98ace3de0 <gen_instance_send_obj>,
    n_args=<optimized out>, n_kw=<optimized out>, args=0x7fce5a919310) at ../../py/objfun.c:82
#24 0x000055a98ac3667e in mp_call_function_n_kw (
    fun_in=0x55a98ace3de0 <gen_instance_send_obj>, n_args=2, n_kw=0, args=0x7fce5a919310)
    at ../../py/runtime.c:726
#25 0x000055a98ac367eb in mp_call_method_n_kw (n_args=<optimized out>, n_kw=<optimized out>,
    args=args@entry=0x7fce5a919308) at ../../py/runtime.c:742
#26 0x000055a98ac51d48 in mp_execute_bytecode (code_state=code_state@entry=0x7fce5a9192e0,
    inject_exc=inject_exc@entry=0x0) at ../../py/vm.c:1042
#27 0x000055a98ac3faa5 in fun_bc_call (self_in=0x7fce5a9005a0, n_args=1, n_kw=0,
    args=0x7ffed951dea0) at ../../py/objfun.c:295
...
#43 0x000055a98ac3faa5 in fun_bc_call (self_in=0x7fce5a8f5320, n_args=0, n_kw=0, args=0x0)
    at ../../py/objfun.c:295
#44 0x000055a98ac3667e in mp_call_function_n_kw (fun_in=0x7fce5a8f5320,
    n_args=n_args@entry=0, n_kw=n_kw@entry=0, args=args@entry=0x0) at ../../py/runtime.c:726
#45 0x000055a98ac366c4 in mp_call_function_0 (fun=<optimized out>) at ../../py/runtime.c:700
#46 0x000055a98ac97cf1 in execute_from_lexer (source_kind=source_kind@entry=3,
    source=<optimized out>, input_kind=input_kind@entry=MP_PARSE_FILE_INPUT,
    is_repl=is_repl@entry=false) at main.c:162
#47 0x000055a98ac97d54 in do_file (file=<optimized out>) at main.c:311
#48 0x000055a98ac983f8 in main_ (argc=argc@entry=2, argv=argv@entry=0x7ffed951e8a8)
    at main.c:740
#49 0x000055a98ac985e1 in main (argc=2, argv=0x7ffed951e8a8) at main.c:491

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy