summaryrefslogtreecommitdiff
path: root/runner
diff options
context:
space:
mode:
authorArkadiusz Hiler <arkadiusz.hiler@intel.com>2020-06-09 17:21:37 +0300
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2020-06-10 18:01:01 +0300
commit0b907087168c13b9bf2ee974020381bba6419d40 (patch)
treee8a7e34ac9a259878f8e8613a62ea2c0a3753252 /runner
parent53b5902d44ba2a9fa9360380cd029e5bfbecac1c (diff)
runner/resultgen: Explain why json creation might have failed
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> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'runner')
-rw-r--r--runner/resultgen.c13
1 files changed, 13 insertions, 0 deletions
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;
+ }
+
write(resultsfd, json_string, strlen(json_string));
close(resultsfd);
return true;