From 1734ca556c81015106a7d533fc9a68192073e22b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 13 Jun 2022 08:40:44 -0400 Subject: [PATCH] Fix: python: free py_config_ptr in component_class_message_iterator_init It looks like we never decref the py_config_ptr object. This causes this leak: Direct leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7fe01c31fc47 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 #1 0x7fe017434b67 in SwigPyObject_New bt2/native_bt.c:1754 #2 0x7fe017436ef8 in SWIG_Python_NewPointerObj bt2/native_bt.c:2336 #3 0x7fe01743cee0 in component_class_message_iterator_init /home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2/native_bt_component_class.i.h:1141 #4 0x7fe01c13d46f in create_self_component_input_port_message_iterator /home/smarchi/src/babeltrace/src/lib/graph/iterator.c:408 #5 0x7fe01c13d877 in bt_message_iterator_create_from_message_iterator /home/smarchi/src/babeltrace/src/lib/graph/iterator.c:468 #6 0x7fe018a251cb in create_msg_iter_on_input_port /home/smarchi/src/babeltrace/src/plugins/utils/muxer/muxer.c:365 #7 0x7fe018a2bd26 in muxer_msg_iter_init_upstream_iterators /home/smarchi/src/babeltrace/src/plugins/utils/muxer/muxer.c:1243 #8 0x7fe018a2c6eb in muxer_msg_iter_init /home/smarchi/src/babeltrace/src/plugins/utils/muxer/muxer.c:1341 #9 0x7fe01c13d46f in create_self_component_input_port_message_iterator /home/smarchi/src/babeltrace/src/lib/graph/iterator.c:408 #10 0x7fe01c13d877 in bt_message_iterator_create_from_message_iterator /home/smarchi/src/babeltrace/src/lib/graph/iterator.c:468 #11 0x7fe0188b9123 in debug_info_msg_iter_init /home/smarchi/src/babeltrace/src/plugins/lttng-utils/debug-info/debug-info.c:1999 #12 0x7fe01c13d46f in create_self_component_input_port_message_iterator /home/smarchi/src/babeltrace/src/lib/graph/iterator.c:408 #13 0x7fe01c13d93b in bt_message_iterator_create_from_sink_component /home/smarchi/src/babeltrace/src/lib/graph/iterator.c:480 #14 0x7fe018a9c665 in details_graph_is_configured /home/smarchi/src/babeltrace/src/plugins/text/details/details.c:418 #15 0x7fe01c1360da in configure_graph /home/smarchi/src/babeltrace/src/lib/graph/graph.c:614 #16 0x7fe01c136718 in bt_graph_run /home/smarchi/src/babeltrace/src/lib/graph/graph.c:688 #17 0x55bdd975fdca in cmd_run /home/smarchi/src/babeltrace/src/cli/babeltrace2.c:2493 #18 0x55bdd9760c3b in main /home/smarchi/src/babeltrace/src/cli/babeltrace2.c:2679 #19 0x7fe01bd6e0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2) ... when I run: $ G_SLICE=always-malloc G_DEBUG=gc-friendly PYTHONMALLOC=malloc tests/utils/run_python_bt2 /home/smarchi/build/babeltrace/tests/../src/cli/babeltrace2 --plugin-path=/home/smarchi/src/babeltrace/tests/data/plugins/flt.lttng-utils.debug-info -c src.test_debug_info.CompleteSrc -c sink.text.details --params with-trace-name=false,with-stream-name=false,with-uuid=false -c flt.lttng-utils.debug-info I see the leak on Ubuntu 20.04, not on Arch. Not sure why. Change-Id: Iad3b1ae78c4f983da27a4e57914af4d5de05ce7e Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/8326 Tested-by: jenkins Reviewed-by: Philippe Proulx --- src/bindings/python/bt2/bt2/native_bt_component_class.i.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bindings/python/bt2/bt2/native_bt_component_class.i.h b/src/bindings/python/bt2/bt2/native_bt_component_class.i.h index 3759335c..8e284c04 100644 --- a/src/bindings/python/bt2/bt2/native_bt_component_class.i.h +++ b/src/bindings/python/bt2/bt2/native_bt_component_class.i.h @@ -1205,6 +1205,7 @@ end: Py_XDECREF(py_comp_cls); Py_XDECREF(py_iter_cls); Py_XDECREF(py_iter_ptr); + Py_XDECREF(py_config_ptr); Py_XDECREF(py_component_port_output_ptr); Py_XDECREF(py_init_method_result); Py_XDECREF(py_iter); -- 2.34.1