From: Petri Latvala <petri.latvala@intel.com>
To: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t] runner/resultgen: Explain why json creation might have failed
Date: Wed, 10 Jun 2020 13:50:21 +0300 [thread overview]
Message-ID: <20200610105021.GJ9497@platvala-desk.ger.corp.intel.com> (raw)
In-Reply-To: <20200609142137.203218-1-arkadiusz.hiler@intel.com>
On Tue, Jun 09, 2020 at 05:21:37PM +0300, Arkadiusz Hiler wrote:
> Sometimes creating the string representation fails. This usually happens
> when we have a huge logs (e.g.: something was spamming the dmesg) or the
> result generation was run on a very low-end system (e.g. embedded board
> with 256 megs of RAM).
>
> Sadly json-c call returns us NULL and provides no explanation
> whatsoever. Let's fix a NULL pointer dereference in such cases and print
> a mesage that should help people make sense out of what have just
> happened.
>
> Cc: Swati Sharma <swati2.sharma@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> ---
> runner/resultgen.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/runner/resultgen.c b/runner/resultgen.c
> index add4aad5..e2e162b0 100644
> --- a/runner/resultgen.c
> +++ b/runner/resultgen.c
> @@ -1661,6 +1661,19 @@ bool generate_results(int dirfd)
> }
>
> json_string = json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PRETTY);
> +
> + if (json_string == NULL) {
> + fprintf(stderr, "resultgen: Failed to create json representation of the results.\n");
> + fprintf(stderr, " This usually means that the results are too big\n");
> + fprintf(stderr, " to fit in the memory as the text representation\n");
> + fprintf(stderr, " is being created.\n\n");
> + fprintf(stderr, " Either something was spamming the logs or your\n");
> + fprintf(stderr, " system is very low on free mem.\n");
> +
> + close(resultsfd);
> + return false;
> + }
> +
There are some obvious arguments that can be made here so I'll tackle
them myself:
"Why not use the serializer function in json-c that directly outputs
to a file?"
That function is implemented with a call to
json_object_to_json_string_ext(). No gain here.
"Why not try to fall back to JSON_C_TO_STRING_PLAIN for a shorter
string result?"
A reasonable argument, but offers very little hope. If we reach this
case it's a heck of a long string as one of the logs and reducing the
overhead of the prettifying won't help much relatively.
An option to limit the disk space usage of a test is in the works and
that will help tackle the root cause of this happening. I assert that
no one really believes it's normal for a single test to log multiple
gigabytes.
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
prev parent reply other threads:[~2020-06-10 10:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-09 14:21 [igt-dev] [PATCH i-g-t] runner/resultgen: Explain why json creation might have failed Arkadiusz Hiler
2020-06-09 15:07 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2020-06-09 17:45 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2020-06-10 10:50 ` Petri Latvala [this message]
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=20200610105021.GJ9497@platvala-desk.ger.corp.intel.com \
--to=petri.latvala@intel.com \
--cc=arkadiusz.hiler@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox