Skip to content

Instantly share code, notes, and snippets.

@andyross
Created August 12, 2022 13:27
Show Gist options
  • Save andyross/d2edbd77463000e57b4c7a39cac31ed7 to your computer and use it in GitHub Desktop.
Save andyross/d2edbd77463000e57b4c7a39cac31ed7 to your computer and use it in GitHub Desktop.
diff --git a/tests/posix/common/src/pthread.c b/tests/posix/common/src/pthread.c
index 6a4c4d267f..4fd4673b9c 100644
--- a/tests/posix/common/src/pthread.c
+++ b/tests/posix/common/src/pthread.c
@@ -596,6 +596,25 @@ ZTEST(posix_apis, test_pthread_descriptor_leak)
for (size_t i = 0; i < CONFIG_MAX_PTHREAD_COUNT * 2; ++i) {
zassert_ok(pthread_create(&pthread1, &attr, create_thread1, NULL),
"unable to create thread %zu", i);
+
+ // Any of the following make the test pass:
+ //k_sleep(K_TICKS(1));
+ //usleep(1);
+ //k_yield();
+ //k_busy_wait(1);
+
+ // So does this, which is far too small to be
+ // impactful as a delay; it generates as just four
+ // instructions!
+ for(volatile int i = 0; i < 1; i++); // ?!!?
+
+ // But this does NOT fix the problem, implying that
+ // the critical state is the extra word on the stack
+ // frame implied by the above code? But I tried a few
+ // different ways to force changes to the stack frame
+ // size without success.
+ //__asm__ volatile("nop; nop; nop; nop");
+
zassert_ok(pthread_join(pthread1, &unused), "unable to join thread %zu", i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment