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
This commit is contained in:
Piotr Tworek 2021-01-12 00:58:52 +01:00 committed by Norman Feske
parent c6d5b98227
commit 53081ac6b3

View File

@ -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;
}