From: Steven Rostedt <rostedt@goodmis.org>
To: Ciunas Bennett <ciunas@linux.ibm.com>
Cc: linux-trace-devel@vger.kernel.org, Yordan Karadzhov <y.karadz@gmail.com>
Subject: Re: [PATCH] kernelshark: Fix TEP filter array parsing logic
Date: Wed, 25 Feb 2026 18:35:42 -0500 [thread overview]
Message-ID: <20260225183542.34135df4@fedora> (raw)
In-Reply-To: <20260224170528.728883-1-ciunas@linux.ibm.com>
On Tue, 24 Feb 2026 17:05:25 +0000
Ciunas Bennett <ciunas@linux.ibm.com> wrote:
Thanks, I'm adding Yordan to the Cc as he's maintaining KernelShark.
-- Steve
> When saving a session with more than a single TEP advanced filter,
> KernelShark triggers a json-c assertion:
>
> "json_object_array_get_idx: Assertion
> `json_object_get_type(jso) == json_type_array' failed."
>
> This is caused because the code reuses the `jfilter` variable inside
> the loop to fetch each array element:
>
> jfilter = json_object_array_get_idx(jfilter, i);
>
> This overwrites the original array object. On the next iteration,
> `jfilter` is no longer a json_type_array, causing the assertion.
>
> Fix this by introducing a temporary variable `jitem` to store each
> array element, leaving `jfilter` to point to the actual array.
>
> Signed-off-by: Ciunas Bennett <ciunas@linux.ibm.com>
> ---
> src/libkshark-configio.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/libkshark-configio.c b/src/libkshark-configio.c
> index 88c2c9a..568ec73 100644
> --- a/src/libkshark-configio.c
> +++ b/src/libkshark-configio.c
> @@ -1528,7 +1528,7 @@ bool kshark_export_adv_filters(struct kshark_context *kshark_ctx, int sd,
> static bool kshark_adv_filters_from_json(struct kshark_data_stream *stream,
> struct json_object *jobj)
> {
> - json_object *jfilter, *jname, *jcond;
> + json_object *jfilter, *jname, *jcond, *jitem;
> int i, length, n, ret = 0;
> char *filter_str = NULL;
>
> @@ -1548,10 +1548,10 @@ static bool kshark_adv_filters_from_json(struct kshark_data_stream *stream,
> /* Set the filter. */
> length = json_object_array_length(jfilter);
> for (i = 0; i < length; ++i) {
> - jfilter = json_object_array_get_idx(jfilter, i);
> + jitem = json_object_array_get_idx(jfilter, i);
>
> - if (!json_object_object_get_ex(jfilter, "name", &jname) ||
> - !json_object_object_get_ex(jfilter, "condition", &jcond))
> + if (!json_object_object_get_ex(jitem, "name", &jname) ||
> + !json_object_object_get_ex(jitem, "condition", &jcond))
> goto fail;
>
> n = asprintf(&filter_str, "%s:%s",
next prev parent reply other threads:[~2026-02-25 23:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 17:05 [PATCH] kernelshark: Fix TEP filter array parsing logic Ciunas Bennett
2026-02-25 23:35 ` Steven Rostedt [this message]
2026-02-27 7:45 ` Yordan Karadzhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260225183542.34135df4@fedora \
--to=rostedt@goodmis.org \
--cc=ciunas@linux.ibm.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=y.karadz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.