Skip to contentSkip to conversation

libxl: abort on memory allocation errors

PATCH In review Marek Marczykowski-Górecki 2 participants 2 messages Dec 11, 2022 – Dec 12, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: abort on memory allocation errors

Use abort() instead of just _exit() in libxl__alloc_failed(). This is more friendly for debugging, as it will trap into debugger, systemd-coredump will collect coredump/backtrace etc. It's much more useful than just "libxl: FATAL ERROR: memory allocation failure (...)" message without context where it actually failed.

---
 tools/libs/light/libxl_internal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/light/libxl_internal.c +1 -1
index 86556b6113b0..c95624933ffc 100644
@@ -36,7 +36,7 @@ void libxl__alloc_failed(libxl_ctx *ctx, const char *func,
     }
 
     fflush(stderr);
-    _exit(-1);
+    abort();
 #undef M_NSIZE
 #undef M_SIZE
 #undef M
Signature · 1 line
2.37.3
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Marek Marczykowski-Górecki

Use abort() instead of just _exit() in libxl__alloc_failed(). This is more friendly for debugging, as it will trap into debugger, systemd-coredump will collect coredump/backtrace etc. It's much more useful than just "libxl: FATAL ERROR: memory allocation failure (...)" message without context where it actually failed.

Thanks,

Signature · 1 line
Anthony PERARD