From 34277f47d8e578ef2c58e4a71209c8220d70890b Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Wed, 20 Sep 2023 16:03:26 +0300 Subject: [PATCH] Extract symbolic-thread-array-init from silver searcher --- .../48-symbolic-thread-array-init.c | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/regression/03-practical/48-symbolic-thread-array-init.c diff --git a/tests/regression/03-practical/48-symbolic-thread-array-init.c b/tests/regression/03-practical/48-symbolic-thread-array-init.c new file mode 100644 index 0000000000..45d5869215 --- /dev/null +++ b/tests/regression/03-practical/48-symbolic-thread-array-init.c @@ -0,0 +1,36 @@ +// Per-thread array pointers passed via argument but initialized before thread create. +// Extracted from silver searcher. +#include +#include +#include +extern int __VERIFIER_nondet_int(); + +void *thread(void *arg) { + int *p = arg; + int i = *p; // NORACE + return NULL; +} + +int main() { + int threads_total = __VERIFIER_nondet_int(); + __goblint_assume(threads_total >= 0); + + pthread_t *tids = malloc(threads_total * sizeof(pthread_t)); + int *is = malloc(threads_total * sizeof(int)); + + // create threads + for (int i = 0; i < threads_total; i++) { + is[i] = i; // NORACE + pthread_create(&tids[i], NULL, &thread, &is[i]); // may fail but doesn't matter + } + + // join threads + for (int i = 0; i < threads_total; i++) { + pthread_join(tids[i], NULL); + } + + free(tids); + free(is); + + return 0; +}