Skip to content

Commit d461019

Browse files
committed
reactor: fail more gracefully when perf_event fd can't be mmaped
In deterministic environments perf_event_open works, but mmaping the file descriptor fails. Don't abort; throw and the system will fall back to another method of backing the CPU stall detector.
1 parent dc1cdf4 commit d461019

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/core/reactor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ cpu_stall_detector_linux_perf_event::cpu_stall_detector_linux_perf_event(file_de
13721372
: cpu_stall_detector(cfg), _fd(std::move(fd)) {
13731373
void* ret = ::mmap(nullptr, 2*getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, _fd.get(), 0);
13741374
if (ret == MAP_FAILED) {
1375-
abort();
1375+
throw std::system_error(errno, std::system_category(), "mmap() failed for perf_event_open");
13761376
}
13771377
_mmap = static_cast<struct ::perf_event_mmap_page*>(ret);
13781378
_data_area = reinterpret_cast<char*>(_mmap) + getpagesize();

0 commit comments

Comments
 (0)