[PATCH] libxl: abort on memory allocation errors

Marek Marczykowski-Górecki posted 1 patch 1 year, 5 months ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20221211175949.2193629-1-marmarek@invisiblethingslab.com
tools/libs/light/libxl_internal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] libxl: abort on memory allocation errors
Posted by Marek Marczykowski-Górecki 1 year, 5 months ago
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.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 tools/libs/light/libxl_internal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libs/light/libxl_internal.c b/tools/libs/light/libxl_internal.c
index 86556b6113b0..c95624933ffc 100644
--- a/tools/libs/light/libxl_internal.c
+++ b/tools/libs/light/libxl_internal.c
@@ -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
-- 
2.37.3


Re: [PATCH] libxl: abort on memory allocation errors
Posted by Anthony PERARD 1 year, 5 months ago
On Sun, Dec 11, 2022 at 06:59:49PM +0100, Marek Marczykowski-Górecki wrote:
> 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.
> 
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

Acked-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,

-- 
Anthony PERARD