Skip to content

Commit 68b8bea

Browse files
theihorAlexei Starovoitov
authored andcommitted
selftests/bpf: Fix double thread join in uprobe_multi_test
ASAN reported a "joining already joined thread" error. The release_child() may be called multiple times for the same struct child. Fix by resetting child->thread to 0 after pthread_join. Also memset(0) static child variable in test_attach_api(). Acked-by: Mykyta Yatsenko <yatsenko@meta.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://lore.kernel.org/r/20260223190736.649171-15-ihor.solodrai@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent f7ac552 commit 68b8bea

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ static void release_child(struct child *child)
6262
return;
6363
close(child->go[1]);
6464
close(child->go[0]);
65-
if (child->thread)
65+
if (child->thread) {
6666
pthread_join(child->thread, NULL);
67+
child->thread = 0;
68+
}
6769
close(child->c2p[0]);
6870
close(child->c2p[1]);
6971
if (child->pid > 0)
@@ -331,6 +333,8 @@ test_attach_api(const char *binary, const char *pattern, struct bpf_uprobe_multi
331333
{
332334
static struct child child;
333335

336+
memset(&child, 0, sizeof(child));
337+
334338
/* no pid filter */
335339
__test_attach_api(binary, pattern, opts, NULL);
336340

0 commit comments

Comments
 (0)