From 4e1d89289153cf5116969e91c48e2c76e69393d2 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Thu, 12 Sep 2019 12:15:16 -0700 Subject: [PATCH] [LibOS] Add missing memory barrier in regression/mmap-file.c Previously, the test could fail if the compiler changed the order of variable assignments (`message` vs `a[4096]`). --- LibOS/shim/test/regression/mmap-file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LibOS/shim/test/regression/mmap-file.c b/LibOS/shim/test/regression/mmap-file.c index 2fdb8823..125c81f4 100644 --- a/LibOS/shim/test/regression/mmap-file.c +++ b/LibOS/shim/test/regression/mmap-file.c @@ -6,7 +6,7 @@ #include #include -const char* message; +static const char* message; void SIGBUS_handler(int sig) { puts(message); @@ -79,6 +79,8 @@ int main(int argc, const char** argv) { } message = pid == 0 ? "mmap test 5 passed\n" : "mmap test 8 passed\n"; + /* need a barrier to assign message before SIGBUS due to a[4096] */ + asm volatile ("nop" ::: "memory"); a[4096] = 0xff; if (signal(SIGBUS, SIG_DFL) == SIG_ERR) {