From beb5169ee902ae7045eaae5b495b430fb917def7 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 8 Mar 2017 08:48:20 +0100 Subject: [PATCH] signal test: fix destruction of nested test The signal_1/2/3 objects (which are threads) are in destruction, but still signals are send to them. When the signal arrive and the memory for the signal_1/2/3 object is already invalid we operate on stale memory and all the locking infrastructure of the Thread don't work anymore. Be more robust, explicitly wait for the termination of the thread. Issue #2284 --- repos/os/src/test/signal/main.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/repos/os/src/test/signal/main.cc b/repos/os/src/test/signal/main.cc index 05a0a48b68..752cdbd3dc 100644 --- a/repos/os/src/test/signal/main.cc +++ b/repos/os/src/test/signal/main.cc @@ -617,6 +617,9 @@ struct Nested_stress_test : Signal_test ~Nested_stress_test() { + /* tell timer not to send any signals anymore. */ + timer.sigh(Timer::Session::Signal_context_capability()); + /* let senders stop burning our CPU time */ sender_1.destruct = true; sender_2.destruct = true; @@ -634,6 +637,9 @@ struct Nested_stress_test : Signal_test sender_1.transmitter.submit(); sender_2.transmitter.submit(); sender_3.transmitter.submit(); + + /* wait until threads joined */ + sender_1.join(); sender_2.join(), sender_3.join(); } void handle_poll()