From a7d538fddb21427681704e027e2fdea2bed686c7 Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Wed, 4 Jul 2018 17:55:40 +0200 Subject: nptl threads: Fix bug in using a weak variable. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case __nptl_nthreads is not defined in the final binary then avoid dereferencing the address since it's null. Anyway this means there is no other thread and so we must exit. * libc/misc/internals/__uClibc_main.c (__uClibc_main): Handle case where &__nptl_nthreads is null. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon --- libc/misc/internals/__uClibc_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c index d8286f20b..849bca8d4 100644 --- a/libc/misc/internals/__uClibc_main.c +++ b/libc/misc/internals/__uClibc_main.c @@ -544,7 +544,7 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc, result = 0; unsigned int *const ptr = &__nptl_nthreads; - if (! atomic_decrement_and_test (ptr)) + if (ptr && ! atomic_decrement_and_test (ptr)) /* Not much left to do but to exit the thread, not the process. */ __exit_thread_inline (0); } -- cgit v1.2.3