[safestack] add a test for the thread cleanup

Tests that a buffer allocated in the stack triggers a segfault.