Actions
Bug #1334
open
SM
Python component class memory leak
Bug #1334:
Python component class memory leak
Start date:
11/29/2021
Due date:
% Done:
0%
Estimated time:
Description
I saw this memory leak when working on a Python sink:
/tmp/babeltrace/bin/babeltrace2 --plugin-path=$PWD net://localhost/host/simark/py_logging -c sink.hello.Hello
11-29 21:49:09.490 566263 566263 W BT2-PY log_exception_and_maybe_append_cause@native_bt_log_and_append_error.h:204 [sink.hello.Hello] Traceback (most recent call last):
File "/home/simark/src/PyConCanada2017/bt_plugin_foo.py", line 10, in _user_consume
raise ValueError("hi")
ValueError: hi
11-29 21:49:09.490 566263 566263 W LIB/GRAPH consume_graph_sink@graph.c:462 Component's "consume" method failed: status=ERROR, comp-addr=0x60c000066ac0, comp-name="sink.hello.Hello", comp-log-level=WARNING, comp-class-type=SINK, comp-class-name="Hello", comp-class-partial-descr="", comp-class-is-frozen=1, comp-input-port-count=1, comp-output-port-count=0
11-29 21:49:09.490 566263 566263 E CLI cmd_run@babeltrace2.c:2537 Graph failed to complete successfully
ERROR: [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2537)
Graph failed to complete successfully
CAUSED BY [libbabeltrace2] (/home/simark/src/babeltrace/src/lib/graph/graph.c:462)
Component's "consume" method failed: status=ERROR, comp-addr=0x60c000066ac0, comp-name="sink.hello.Hello", comp-log-level=WARNING, comp-class-type=SINK,
comp-class-name="Hello", comp-class-partial-descr="", comp-class-is-frozen=1, comp-input-port-count=1, comp-output-port-count=0
CAUSED BY [sink.hello.Hello: 'sink.hello.Hello'] (/home/simark/src/babeltrace/src/bindings/python/bt2/bt2/native_bt_log_and_append_error.h:102)
Traceback (most recent call last):
File "/home/simark/src/PyConCanada2017/bt_plugin_foo.py", line 10, in _user_consume
raise ValueError("hi")
ValueError: hi
=================================================================
==566263==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 184 byte(s) in 1 object(s) allocated from:
#0 0x7f10290c2459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
#1 0x7f1028d48121 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x5d121)
#2 0x7f1024605c08 in bt_bt2_component_class_sink_create /home/simark/src/babeltrace/src/bindings/python/bt2/bt2/native_bt_component_class.i.h:1485
#3 0x7f1024622599 in _wrap_bt2_component_class_sink_create bt2/native_bt.c:7300
#4 0x7f1025090c37 (/usr/lib/libpython3.9.so.1.0+0x148c37)
SUMMARY: AddressSanitizer: 184 byte(s) leaked in 1 allocation(s).
The file containing the component class:
import bt2
@bt2.plugin_component_class
class Hello(bt2._UserSinkComponent):
def __init__(self, config, params, obj):
self._port = self._add_input_port("port")
def _user_consume(self):
raise ValueError("hi")
bt2.register_plugin(__name__, "hello")
Actions