[vm/bin] Improve error message in WakeupHandler

Instead of writing errno into stderr via perror include it into
FATAL message. This will help us to dignoze the problem in
environments where FATAL messages are preserved as part of the
crash report.

TEST=tested manually by changing write() parameters to be invalid

Bug: b/279184589
Change-Id: I45424af6064f9eec258a3bff1f96488b8a60f095
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298862
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
This commit is contained in:
Vyacheslav Egorov 2023-05-02 07:32:30 +00:00 committed by Commit Queue
parent 50f65c4f39
commit 2b9140a8f7
4 changed files with 19 additions and 10 deletions

View file

@ -104,10 +104,10 @@ class InterruptMessage {
int64_t data;
};
static constexpr int kInterruptMessageSize = sizeof(InterruptMessage);
static constexpr int kInfinityTimeout = -1;
static constexpr int kTimerId = -1;
static constexpr int kShutdownId = -2;
static constexpr intptr_t kInterruptMessageSize = sizeof(InterruptMessage);
static constexpr intptr_t kInfinityTimeout = -1;
static constexpr intptr_t kTimerId = -1;
static constexpr intptr_t kShutdownId = -2;
template <typename T>
class CircularLinkedList {

View file

@ -178,9 +178,12 @@ void EventHandlerImplementation::WakeupHandler(intptr_t id,
FDUtils::WriteToBlocking(interrupt_fds_[1], &msg, kInterruptMessageSize);
if (result != kInterruptMessageSize) {
if (result == -1) {
perror("Interrupt message failure:");
FATAL("Interrupt message failure: %s", strerror(errno));
} else {
FATAL("Interrupt message failure: expected to write %" Pd
" bytes, but wrote %" Pd ".",
kInterruptMessageSize, result);
}
FATAL("Interrupt message failure. Wrote %" Pd " bytes.", result);
}
}

View file

@ -186,9 +186,12 @@ void EventHandlerImplementation::WakeupHandler(intptr_t id,
FDUtils::WriteToBlocking(interrupt_fds_[1], &msg, kInterruptMessageSize);
if (result != kInterruptMessageSize) {
if (result == -1) {
perror("Interrupt message failure:");
FATAL("Interrupt message failure: %s", strerror(errno));
} else {
FATAL("Interrupt message failure: expected to write %" Pd
" bytes, but wrote %" Pd ".",
kInterruptMessageSize, result);
}
FATAL("Interrupt message failure. Wrote %" Pd " bytes.", result);
}
}

View file

@ -194,9 +194,12 @@ void EventHandlerImplementation::WakeupHandler(intptr_t id,
FDUtils::WriteToBlocking(interrupt_fds_[1], &msg, kInterruptMessageSize);
if (result != kInterruptMessageSize) {
if (result == -1) {
perror("Interrupt message failure:");
FATAL("Interrupt message failure: %s", strerror(errno));
} else {
FATAL("Interrupt message failure: expected to write %" Pd
" bytes, but wrote %" Pd ".",
kInterruptMessageSize, result);
}
FATAL("Interrupt message failure. Wrote %" Pd " bytes.", result);
}
}