Skip to content

segmentation fault when instantiating a D4File #118

@scimerc

Description

@scimerc

running the script /tmp/test.py:

from pyd4 import D4File

f = D4File("test.d4")

runs fine with Python 3.12.3 and d4-format v0.3.10 but results in a segmentation fault with Python 3.14 and d4-format v0.3.10.

GDB output:

(gdb) run /tmp/test.py 
Starting program: /home/franbe/.virtualenvs/default/bin/python /tmp/test.py

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.ubuntu.com>
Enable debuginfod for this session? (y or [n]) 
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
pyo3::types::string::{impl#12}::extract (ob=0xffffffffffffffff) at src/types/string.rs:363
363	        <PyString as PyTryFrom>::try_from(ob)?.to_str()
(gdb) backtrace 
#0  pyo3::types::string::{impl#12}::extract (ob=0xffffffffffffffff) at src/types/string.rs:363
#1  0x00007ffff6a89b8f in pyo3::types::any::PyAny::extract<&str> (self=0xffffffffffffffff)
    at /home/franbe/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-0.17.3/src/types/any.rs:789
#2  pyo3::impl_::extract_argument::{impl#0}::extract<&str> (obj=0xffffffffffffffff)
    at /home/franbe/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-0.17.3/src/impl_/extract_argument.rs:30
#3  pyo3::impl_::extract_argument::extract_argument<&str> (obj=0xffffffffffffffff, arg_name=..., 
    holder=<optimized out>)
    at /home/franbe/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-0.17.3/src/impl_/extract_argument.rs:88
#4  _pyd4::d4file::_::{impl#1}::__pymethod___new____::{closure#0} () at pyd4/src/d4file.rs:71
#5  std::panicking::catch_unwind::do_call<_pyd4::d4file::_::{impl#1}::__pymethod___new____::{closure_env#0}, core::result::Result<*mut pyo3_ffi::object::PyObject, pyo3::err::PyErr>> (
    data=<error reading variable: Cannot access memory at address 0x0>)
    at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/panicking.rs:590
#6  std::panicking::catch_unwind<core::result::Result<*mut pyo3_ffi::object::PyObject, pyo3::err::PyErr>, _pyd4::d4file::_::{impl#1}::__pymethod___new____::{closure_env#0}> (f=...)
    at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/panicking.rs:553
#7  std::panic::catch_unwind<_pyd4::d4file::_::{impl#1}::__pymethod___new____::{closure_env#0}, core::result::Result<*mut pyo3_ffi::object::PyObject, pyo3::err::PyErr>> (f=...)
    at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/panic.rs:359
#8  _pyd4::d4file::D4File::__pymethod___new____ (subtype=0x555555ffe850, _args=0x7ffff6f1a240, _kwargs=0x0)
    at pyd4/src/d4file.rs:62
#9  0x000055555574c10d in type_call (self=self@entry=0x555555ffe850, args=args@entry=0x7ffff6f1a240, 
    kwds=kwds@entry=0x0) at Objects/typeobject.c:2309
#10 0x000055555570e527 in _PyObject_MakeTpCall (tstate=0x555555aeb108 <_PyRuntime+315624>, callable=0x555555ffe850, 
    args=<optimized out>, nargs=1, keywords=0x0) at Objects/call.c:242
#11 0x0000555555776f4c in _PyEval_EvalFrameDefault (tstate=0x555555aeb108 <_PyRuntime+315624>, frame=0x7ffff7fb2020, 
    throwflag=-151936448, throwflag@entry=0) at Python/generated_cases.c.h:1619
#12 0x00005555557750e1 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb2020, 
    tstate=0x555555aeb108 <_PyRuntime+315624>) at ./Include/internal/pycore_ceval.h:121
#13 _PyEval_Vector (tstate=tstate@entry=0x555555aeb108 <_PyRuntime+315624>, func=func@entry=0x7ffff6f2b5e0, 
    locals=locals@entry=0x7ffff6f31a80, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0)
--Type <RET> for more, q to quit, c to continue without paging--
    at Python/ceval.c:2083
#14 0x000055555581a130 in PyEval_EvalCode (co=0x7ffff6f52330, globals=<optimized out>, locals=0x7ffff6f31a80)
    at Python/ceval.c:975
#15 0x000055555583a75e in run_mod (mod=mod@entry=0x555555c760c8, filename=filename@entry=0x7ffff6fc5af0, 
    globals=globals@entry=0x7ffff6f31a80, locals=locals@entry=0x7ffff6f31a80, flags=flags@entry=0x7fffffffcf08, 
    arena=arena@entry=0x7ffff7b1be30, interactive_src=0x0, generate_new_source=0) at Python/pythonrun.c:1459
#16 0x000055555583a6b5 in pyrun_file (fp=fp@entry=0x555555b5e420, filename=filename@entry=0x7ffff6fc5af0, 
    start=start@entry=257, globals=globals@entry=0x7ffff6f31a80, locals=locals@entry=0x7ffff6f31a80, 
    closeit=closeit@entry=1, flags=0x7fffffffcf08) at Python/pythonrun.c:1293
#17 0x000055555583a529 in _PyRun_SimpleFileObject (fp=fp@entry=0x555555b5e420, filename=filename@entry=0x7ffff6fc5af0, 
    closeit=closeit@entry=1, flags=flags@entry=0x7fffffffcf08) at Python/pythonrun.c:521
#18 0x000055555583a348 in _PyRun_AnyFileObject (fp=0x555555b5e420, filename=filename@entry=0x7ffff6fc5af0, 
    closeit=closeit@entry=1, flags=flags@entry=0x7fffffffcf08) at Python/pythonrun.c:81
#19 0x0000555555843b31 in pymain_run_file_obj (skip_source_first_line=0, filename=0x7ffff6fc5af0, 
    program_name=0x7ffff6fac450) at Modules/main.c:410
#20 pymain_run_file (config=0x555555ab61d0 <_PyRuntime+98736>) at Modules/main.c:429
#21 pymain_run_python (exitcode=0x7fffffffcefc) at Modules/main.c:694
#22 Py_RunMain () at Modules/main.c:775
#23 0x000055555584353b in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:829
#24 0x00007ffff7c2a1ca in __libc_start_call_main (main=main@entry=0x5555556eb040 <main>, argc=argc@entry=2, 
    argv=argv@entry=0x7fffffffd168) at ../sysdeps/nptl/libc_start_call_main.h:58
#25 0x00007ffff7c2a28b in __libc_start_main_impl (main=0x5555556eb040 <main>, argc=2, argv=0x7fffffffd168, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd158)
    at ../csu/libc-start.c:360
#26 0x00005555557b7e25 in _start ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions