From 53081ac6b3c6474d83d5cb870e917fb8cc8dce38 Mon Sep 17 00:00:00 2001 From: Piotr Tworek Date: Tue, 12 Jan 2021 00:58:52 +0100 Subject: [PATCH] libc: Dont't use local_addr in try/catch block. The code in Libc::Cloned_malloc_heap_range initializes its local_addr member variable by calling Region_map::attach_at. This function can throw Region_conflict exception. The handler for this exception uses the local_addr to produce an error message. Such error log is IHMO useless, or even incorrect since the value of local_addr is undefined in such case. Its also worth noting that clang 12 produces the following warning for this code: "cannot refer to a non-static member from the handler of a constructor function try block" Issue #3985 --- repos/libports/src/lib/libc/internal/cloned_malloc_heap_range.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/libports/src/lib/libc/internal/cloned_malloc_heap_range.h b/repos/libports/src/lib/libc/internal/cloned_malloc_heap_range.h index 93ccbd0300..60d19c10fd 100644 --- a/repos/libports/src/lib/libc/internal/cloned_malloc_heap_range.h +++ b/repos/libports/src/lib/libc/internal/cloned_malloc_heap_range.h @@ -40,7 +40,7 @@ struct Libc::Cloned_malloc_heap_range local_addr(rm.attach_at(ds, (addr_t)start)) { } catch (Region_map::Region_conflict) { - error("could not clone heap region ", Hex_range(local_addr, size)); + error("could not clone heap region ", Hex_range((addr_t)start, size)); throw; }