Actually enforce the size in ChannelPreallocatedAllocator
We were ignoring the size when being asked to allocate. Turns out
Flatbuffers rounds alignment up, so a 300 byte request becomes 304
bytes, corrupting the redzone. Add a bunch of CHECKs here to catch it,
teach EventLoop to catch it, and catch it in the compiler.
Change-Id: I10488a2f96eeb7a955c6da436e6f9de1fcebbd14
diff --git a/aos/events/event_loop_param_test.h b/aos/events/event_loop_param_test.h
index 57d0525..85e802b 100644
--- a/aos/events/event_loop_param_test.h
+++ b/aos/events/event_loop_param_test.h
@@ -59,6 +59,35 @@
// Advances time by sleeping. Can't be called from inside a loop.
virtual void SleepFor(::std::chrono::nanoseconds duration) = 0;
+ // Sets the config to a config with a max size with an invalid alignment.
+ void InvalidChannelAlignment() {
+ flatbuffer_ = JsonToFlatbuffer<Configuration>(R"config({
+ "channels": [
+ {
+ "name": "/aos",
+ "type": "aos.logging.LogMessageFbs"
+ },
+ {
+ "name": "/aos",
+ "type": "aos.timing.Report"
+ },
+ {
+ "name": "/test",
+ "type": "aos.TestMessage",
+ "max_size": 13
+ },
+ {
+ "name": "/test1",
+ "type": "aos.TestMessage"
+ },
+ {
+ "name": "/test2",
+ "type": "aos.TestMessage"
+ }
+ ]
+})config");
+ }
+
void PinReads() {
static const std::string kJson = R"config({
"channels": [
@@ -245,6 +274,8 @@
return factory_->MakePrimary(name);
}
+ void InvalidChannelAlignment() { factory_->InvalidChannelAlignment(); }
+
void EnableNodes(std::string_view my_node) { factory_->EnableNodes(my_node); }
void Run() { return factory_->Run(); }