Print out which queue was corrupted
When the redzone code catches corruption, it used to just fail with
little extra info on what went wrong. Propegate that error up 1 layer
so we can crash with the channel name.
Change-Id: I6d7fbf808ca616abaf4d680abcf958c5d024829d
diff --git a/aos/events/event_loop_tmpl.h b/aos/events/event_loop_tmpl.h
index 5ca1067..12953d1 100644
--- a/aos/events/event_loop_tmpl.h
+++ b/aos/events/event_loop_tmpl.h
@@ -260,7 +260,7 @@
timing_.handler_time.Add(handler_latency);
// If the handler too too long so we blew by the previous deadline, we
- // want to just try for the next deadline. Rescuedule.
+ // want to just try for the next deadline. Reschedule.
if (monotonic_end_time > phased_loop_.sleep_time()) {
Reschedule(schedule, monotonic_end_time);
}
diff --git a/aos/events/shm_event_loop.cc b/aos/events/shm_event_loop.cc
index 406325d..04d139f 100644
--- a/aos/events/shm_event_loop.cc
+++ b/aos/events/shm_event_loop.cc
@@ -537,9 +537,12 @@
CHECK_LE(length, static_cast<size_t>(channel()->max_size()))
<< ": Sent too big a message on "
<< configuration::CleanedChannelToString(channel());
- lockless_queue_sender_.Send(
+ CHECK(lockless_queue_sender_.Send(
length, monotonic_remote_time, realtime_remote_time, remote_queue_index,
- &monotonic_sent_time_, &realtime_sent_time_, &sent_queue_index_);
+ &monotonic_sent_time_, &realtime_sent_time_, &sent_queue_index_))
+ << ": Somebody wrote outside the buffer of their message on channel "
+ << configuration::CleanedChannelToString(channel());
+
wake_upper_.Wakeup(event_loop()->priority());
return true;
}
@@ -551,10 +554,12 @@
CHECK_LE(length, static_cast<size_t>(channel()->max_size()))
<< ": Sent too big a message on "
<< configuration::CleanedChannelToString(channel());
- lockless_queue_sender_.Send(reinterpret_cast<const char *>(msg), length,
+ CHECK(lockless_queue_sender_.Send(reinterpret_cast<const char *>(msg), length,
monotonic_remote_time, realtime_remote_time,
remote_queue_index, &monotonic_sent_time_,
- &realtime_sent_time_, &sent_queue_index_);
+ &realtime_sent_time_, &sent_queue_index_))
+ << ": Somebody wrote outside the buffer of their message on channel "
+ << configuration::CleanedChannelToString(channel());
wake_upper_.Wakeup(event_loop()->priority());
// TODO(austin): Return an error if we send too fast.
return true;
diff --git a/aos/ipc_lib/lockless_queue.cc b/aos/ipc_lib/lockless_queue.cc
index 6774489..45d9e16 100644
--- a/aos/ipc_lib/lockless_queue.cc
+++ b/aos/ipc_lib/lockless_queue.cc
@@ -903,7 +903,7 @@
return message->data(memory_->message_data_size());
}
-void LocklessQueueSender::Send(
+bool LocklessQueueSender::Send(
const char *data, size_t length,
aos::monotonic_clock::time_point monotonic_remote_time,
aos::realtime_clock::time_point realtime_remote_time,
@@ -916,11 +916,12 @@
// going to write an explicit chunk of memory into the buffer, we need to
// adhere to this convention and place it at the end.
memcpy((reinterpret_cast<char *>(Data()) + size() - length), data, length);
- Send(length, monotonic_remote_time, realtime_remote_time, remote_queue_index,
- monotonic_sent_time, realtime_sent_time, queue_index);
+ return Send(length, monotonic_remote_time, realtime_remote_time,
+ remote_queue_index, monotonic_sent_time, realtime_sent_time,
+ queue_index);
}
-void LocklessQueueSender::Send(
+bool LocklessQueueSender::Send(
size_t length, aos::monotonic_clock::time_point monotonic_remote_time,
aos::realtime_clock::time_point realtime_remote_time,
uint32_t remote_queue_index,
@@ -935,8 +936,9 @@
// modifying it right now.
const Index scratch_index = sender->scratch_index.RelaxedLoad();
Message *const message = memory_->GetMessage(scratch_index);
- CHECK(!CheckBothRedzones(memory_, message))
- << ": Somebody wrote outside the buffer of their message";
+ if (CheckBothRedzones(memory_, message)) {
+ return false;
+ }
// We should have invalidated this when we first got the buffer. Verify that
// in debug mode.
@@ -1083,6 +1085,7 @@
// If anybody is looking at this message (they shouldn't be), then try telling
// them about it (best-effort).
memory_->GetMessage(new_scratch)->header.queue_index.RelaxedInvalidate();
+ return true;
}
int LocklessQueueSender::buffer_index() const {
diff --git a/aos/ipc_lib/lockless_queue.h b/aos/ipc_lib/lockless_queue.h
index b71bd7f..a5de6cc 100644
--- a/aos/ipc_lib/lockless_queue.h
+++ b/aos/ipc_lib/lockless_queue.h
@@ -303,7 +303,7 @@
// Note: calls to Data() are expensive enough that you should cache it.
size_t size() const;
void *Data();
- void Send(size_t length,
+ bool Send(size_t length,
aos::monotonic_clock::time_point monotonic_remote_time =
aos::monotonic_clock::min_time,
aos::realtime_clock::time_point realtime_remote_time =
@@ -314,7 +314,7 @@
uint32_t *queue_index = nullptr);
// Sends up to length data. Does not wakeup the target.
- void Send(const char *data, size_t length,
+ bool Send(const char *data, size_t length,
aos::monotonic_clock::time_point monotonic_remote_time =
aos::monotonic_clock::min_time,
aos::realtime_clock::time_point realtime_remote_time =