Messages in this thread Patch in this message | | | From | Janne Huttunen <> | Subject | [PATCH] perf script python: Fix dict reference counting | Date | Fri, 6 Jul 2018 09:53:44 +0300 |
| |
The dictionaries are attached to the parameter tuple that steals the references. The code should not decrement the reference counters explicitly. Otherwise the objects might be released while they are still in use which may cause perf crashes, assertions or just plain weird behavior like unexpected data changes in stored objects.
Signed-off-by: Janne Huttunen <janne.huttunen@nokia.com> --- tools/perf/util/scripting-engines/trace-event-python.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 46e9e19..60fce44 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -908,14 +908,11 @@ static void python_process_tracepoint(struct perf_sample *sample, if (_PyTuple_Resize(&t, n) == -1) Py_FatalError("error resizing Python tuple"); - if (!dict) { + if (!dict) call_object(handler, t, handler_name); - } else { + else call_object(handler, t, default_handler_name); - Py_DECREF(dict); - } - Py_XDECREF(all_entries_dict); Py_DECREF(t); } @@ -1235,7 +1232,6 @@ static void python_process_general_event(struct perf_sample *sample, call_object(handler, t, handler_name); - Py_DECREF(dict); Py_DECREF(t); } -- 2.5.5
| |