[LTP] pthread_detach_1-2: Fix failure on modern glibc
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Fri May 15 11:56:01 CEST 2026
Hi Wei,
On Sat, 9 May 2026, Wei Gao wrote:
> pthread_detach_1-2: Fix failure on modern glibc
> + /* Wait for the main thread to allow exit */
> + do {
> + ret = sem_wait(&sem_exit);
> + }
> + while ((ret == -1) && (errno == EINTR));
> + if (ret == -1) {
> + UNRESOLVED(errno, "Failed to wait for the exit semaphore");
> + }
[...]
> + ret = sem_init(&sem_exit, 0, 0);
> + if (ret != 0) {
> + UNRESOLVED(errno, "Failed to init the exit semaphore");
> + }
[...]
> + sem_destroy(&sem_exit);
Fix looks correct. The extra semaphore ensures the child stays alive past
the pthread_join() probe, so glibc reliably sees THREAD_STATE_DETACHED
and returns EINVAL rather than ESRCH.
Reviewed-by: LTP AI Reviewer <ltp-ai@noreply.github.com>
Pre-existing issues noticed in the surrounding code (not introduced
by this patch):
- 1-2.c:5 — testfrmw.h used instead of posixtest.h; entry point is
test_main() rather than main() — established convention for this
test framework subdirectory.
- 1-2.c:178 — break inside #if VERBOSE > 0 causes case 1 fall-through
when VERBOSE=0; harmless because case 2/default are also gated by the
same #ifdef.
---
Note:
Our agent completed the review of the patch.
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list