public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] runner/resultgen: Explain why json creation might have failed
@ 2020-06-09 14:21 Arkadiusz Hiler
  2020-06-09 15:07 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arkadiusz Hiler @ 2020-06-09 14:21 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala

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;
+	}
+
 	write(resultsfd, json_string, strlen(json_string));
 	close(resultsfd);
 	return true;
-- 
2.25.4

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-10 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [igt-dev] [PATCH i-g-t] " Petri Latvala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox