Skip to content

Commit

Permalink
Convince compiler to use constructor MemoryRange(addr, end).
Browse files Browse the repository at this point in the history
A default build (no additional cmake options) in a 32-bit Debian Bookworm
was observed to use the constructor MemoryRange(addr, size)
instead of MemoryRange(addr, end).
This triggered a crash of the chaos_oom test, because it tried to
use the last part of the address space, which results later in
following fatal message, because end_ wraps over to the value 0.

[FATAL src/MemoryRange.h:20:MemoryRange()] start_ <= end_
  • Loading branch information
bernhardu authored and rocallahan committed Sep 26, 2024
1 parent 6f1b173 commit 5dff262
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/AddressSpace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,9 @@ remote_ptr<void> AddressSpace::chaos_mode_find_free_memory(RecordTask* t,
MemoryRange global_exclusion_range = get_global_exclusion_range(&t->session());
// NB: Above RR_PAGE_ADDR is probably not free anyways, but if it somehow is
// don't hand it out again.
static MemoryRange rrpage_so_range = MemoryRange(RR_PAGE_ADDR - PRELOAD_LIBRARY_PAGE_SIZE, RR_PAGE_ADDR + PRELOAD_LIBRARY_PAGE_SIZE);
static MemoryRange rrpage_so_range = MemoryRange(remote_ptr<void>(RR_PAGE_ADDR - PRELOAD_LIBRARY_PAGE_SIZE),
remote_ptr<void>(RR_PAGE_ADDR + PRELOAD_LIBRARY_PAGE_SIZE));
assert(rrpage_so_range.size() == 2 * PRELOAD_LIBRARY_PAGE_SIZE);

// Ignore the hint half the time.
if (hint && (random() & 1)) {
Expand Down

0 comments on commit 5dff262

Please sign in to comment.