From 51cebdae2d65fd93e2541215c1e845c760ba0d9e Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 9 Jan 2022 20:01:12 +0000 Subject: [PATCH] abort() is now called if a heap mapping fails --- photon/libc/sys/horizon/heap.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/photon/libc/sys/horizon/heap.c b/photon/libc/sys/horizon/heap.c index 84f6418..ce5c076 100644 --- a/photon/libc/sys/horizon/heap.c +++ b/photon/libc/sys/horizon/heap.c @@ -1,8 +1,12 @@ #include #include +#include #include +#include #include #include +#include +#include #include #define ROUND_UP(x, b) x += (b) - ((x) % (b)) @@ -56,9 +60,15 @@ void *__crt_heap_extend(size_t sz) mx_vmar_bounds(mx_bootstrap_handle_get(MX_B_VMAR_ROOT), &vmar_base, NULL); size_t offset = heap_end - vmar_base; - mx_vmar_map(mx_bootstrap_handle_get(MX_B_VMAR_ROOT), + mx_status_t err = mx_vmar_map(mx_bootstrap_handle_get(MX_B_VMAR_ROOT), MX_VM_PERM_READ | MX_VM_PERM_WRITE | MX_VM_SPECIFIC, offset, heap_vmo, heap_sz, sz, &alloc_base); + + if (err != MX_OK) { + printf("cannot map extended heap: %s\n", mx_status_to_string(err)); + abort(); + } + heap_sz += sz; void *out = (void *)heap_end;