Actions
Bug #1439
open
CB
babeltrace Python bindings segfault on Python 3.14 when reading trace
Bug #1439:
babeltrace Python bindings segfault on Python 3.14 when reading trace
Start date:
04/30/2026
Due date:
% Done:
0%
Estimated time:
Description
Files to reproduce¶
- Create `/tmp/babeltrace1.5-python`
- Unzip `trace.tar.xz` into `/tmp/babeltrace1.5-python/trace/`
- Create the following Python script `/tmp/babeltrace1.5-python/trace/repro_minimal.py`:
"""
Minimal reproducer.
Opens an existing CTF/LTTng trace with babeltrace1's Python bindings and
iterates field names per event. On Python 3.14 / Ubuntu 26.04, this segfaults
inside `_bt_python_field_one_from_list` because the C wrapper returns a NULL
list pointer with an uninitialized count.
Reader is assumed to have the trace at the path below.
"""
import sys
import faulthandler
faulthandler.enable()
import babeltrace
TRACE_DIR = '/tmp/babeltrace1.5-python/trace'
print(f'Python: {sys.version.splitlines()[0]}')
print(f'babeltrace: {babeltrace.__version__}')
print(f'Trace dir: {TRACE_DIR}')
tc = babeltrace.TraceCollection()
tc.add_traces_recursive(TRACE_DIR, 'ctf')
for event in tc.events:
print(f'event {event.name!r} ts={event.timestamp}')
print(' about to call event.keys() ...', flush=True)
keys = event.keys() # <-- crashes here on Python 3.14
print(f' keys = {keys}')
print('DONE')
Steps reproduce on Python 3.14 and Ubuntu 26.04¶
$ docker run --rm -it -v /tmp/babeltrace1.5-python:/tmp/babeltrace1.5-python ubuntu:26.04 bash -c ' apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq python3-babeltrace && python3 --version && python3 /tmp/babeltrace1.5-python/repro_minimal.py '
Actual output output with Python 3.14 (Ubuntu 26.04): segfault¶
Python 3.14.4 Python: 3.14.4 (main, Apr 8 2026, 04:02:31) [GCC 15.2.0] babeltrace: 1.5.11 Trace dir: /tmp/babeltrace1.5-python/trace event 'lttng_ust_tracef:event' ts=1777503018164567458 about to call event.keys() ... Fatal Python error: Segmentation fault Current thread 0x000072cf0dcc51c0 [python3] (most recent call first): File "/usr/lib/python3/dist-packages/babeltrace/babeltrace.py", line 83 in _bt_python_field_one_from_list File "/usr/lib/python3/dist-packages/babeltrace/babeltrace.py", line 839 in _field_list_with_scope File "/usr/lib/python3/dist-packages/babeltrace/babeltrace.py", line 719 in field_list_with_scope File "/usr/lib/python3/dist-packages/babeltrace/babeltrace.py", line 792 in keys File "/tmp/babeltrace1.5-python/repro_minimal.py", line 29 in <module> Current thread's C stack trace (most recent call first): Binary file "python3", at _Py_DumpStack+0x4a [0x476e25] Binary file "python3" [0x504188] Binary file "/usr/lib/x86_64-linux-gnu/libc.so.6", at +0x45cb0 [0x72cf0dd0bcb0] Binary file "/usr/lib/python3/dist-packages/babeltrace/_babeltrace.cpython-314-x86_64-linux-gnu.so", at _bt_python_field_one_from_list+0x7 [0x72cf0d9bc627] Binary file "/usr/lib/python3/dist-packages/babeltrace/_babeltrace.cpython-314-x86_64-linux-gnu.so", at +0x156b5 [0x72cf0d9bc6b5] Binary file "python3" [0x5772b9] Binary file "python3", at _PyObject_MakeTpCall+0x36c [0x52f3fc] Binary file "python3", at _PyEval_EvalFrameDefault+0xe66 [0x54d936] Binary file "python3", at PyEval_EvalCode+0x106 [0x547bd6] Binary file "python3" [0x6cb701] Binary file "python3" [0x6c82b1] Binary file "python3" [0x6c795b] Binary file "python3" [0x6c7429] Binary file "python3", at Py_RunMain+0x349 [0x6c50e9] Binary file "python3", at Py_BytesMain+0x34 [0x6744b4] Binary file "/usr/lib/x86_64-linux-gnu/libc.so.6", at +0x2a601 [0x72cf0dcf0601] Binary file "/usr/lib/x86_64-linux-gnu/libc.so.6", at __libc_start_main+0x88 [0x72cf0dcf0718] Binary file "python3", at _start+0x25 [0x6738b5] Extension modules: babeltrace._babeltrace (total: 1)
Expected output == actual output on Python 3.12 (Ubuntu 24.04): works¶
Just change the Docker image to `ubundu:24.04`:
Python 3.12.3 Python: 3.12.3 (main, Mar 23 2026, 19:04:32) [GCC 13.3.0] babeltrace: 1.5.11 Trace dir: /tmp/babeltrace1.5-python/trace event 'lttng_ust_tracef:event' ts=1777503018164567458 about to call event.keys() ... keys = ['cpu_id', 'content_size', 'id', 'v', 'procname', 'vtid', 'packet_seq_num', 'uuid', 'timestamp_end', 'events_discarded', 'stream_instance_id', 'timestamp_begin', 'magic', 'stream_id', '_msg_length', 'vpid', 'msg', 'packet_size'] event 'lttng_ust_tracef:event' ts=1777503018178240108 about to call event.keys() ... keys = ['cpu_id', 'content_size', 'id', 'v', 'procname', 'vtid', 'packet_seq_num', 'uuid', 'timestamp_end', 'events_discarded', 'stream_instance_id', 'timestamp_begin', 'magic', 'stream_id', '_msg_length', 'vpid', 'msg', 'packet_size'] event 'ros2:rmw_publisher_init' ts=1777503018183106175 ... DONE
Files
Actions