bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pthread library


From: 최광훈
Subject: pthread library
Date: 3 Jan 2001 20:06:38 +0900



In glibc 2.1.3, I found a bug, though I am not sure. The pthread library ($GLIBC/linuxthreads)
contains pthread.c, which contains the function __pthread_find_self(). This function
seems to omit one possible control branch. Here is its definition:

pthread_descr __pthread_find_self()
{
char * sp = CURRENT_STACK_FRAME;
#ifdef __uclinux__
pthread_descr th = __pthread_initial_thread.p_nextlive ;

myputs("__pthread_find_self\n");

myputs("__pthread_find_self : 1\n");

while (th != &__pthread_initial_thread)
{
myputs("__pthread_find_self : 2\n");

if ((sp <= (char*)th ) && ( sp >= __pthread_handles[th->p_nr].h_bottom))
{
myputs("__pthread_find_self : 3\n");

return th;
}

myputs("__pthread_find_self : 4\n");

th = th->p_nextlive ;
}

myputs("__pthread_find_self : 5\n");
#else
pthread_handle h;
/* __pthread_handles[0] is the initial thread, __pthread_handles[1] is
the manager threads handled specially in thread_self(), so start at 2 */

myputs("__pthread_find_self : 6\n");

h = __pthread_handles + 2;

myputs("__pthread_find_self : 7\n");

while (! (sp <= (char *) h->h_descr && sp >= h->h_bottom)) {

myputs("__pthread_find_self : 8\n");

h++;
}

myputs("__pthread_find_self : 9\n");

return h->h_descr;
#endif
}

In the above definition, the function myputs is my own printf-like function to examine
program control. One possible run that gets crashed is shown below. The reason
for crashing is the condition check in while is weak a little because there can
be (th == &__pthread_initial_thread), i.e. there is only one thread. Even if authors
know the missing branch cannot be selected by a certain reason, it would be
better to put some assertion for the branch.

__libc_start_main
__libc_start_main : 1
__libc_start_main : 2
__libc_start_main : 3
__libc_start_main : 5
__libc_init_first
$(GLIBC)/sysdeps/unix/sysv/uclinux/init-first.c::init
Call __libc_init in $(GLIBC)/sysdeps/unix/sysv/uclinux/init-first.c::init
__libc_start_main : 6
__libc_start_main : 7
pthread_initialize -------------------------> pthread relevant
init_rtsigs -------------------------> pthread relevant
#ifndef __i386__ ...
before swi
after swi
before swi
after swi
before swi
after swi
__libc_start_main : 8
__libc_start_main : 9
... vfork ...
... parent
__pthread_reset_main_thread --------------------------> pthread relevant
thread_self (#ifdef __uclinux__) --------------------------> pthread relevant
__pthread_find_self ---------------------------> pthread relevant
__pthread_find_self : 1
__pthread_find_self : 5 ................> A MISSING BRANCH !!!!!
Internal error: Oops - undefined instruction: 1

Is this a really a bug ?

Thank you for reading my mail. Please forward your reply to address@hidden
though I will check the bug-glibc mail archive regularly.

Kwanghoon
reply via email to

[Prev in Thread] Current Thread [Next in Thread]