This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
setting of initial bottom of stack variable in pthread.c (again)
- From: Jay <j2list468 at yahoo dot com>
- To: libc-ports at sourceware dot org
- Date: Tue, 8 Aug 2006 08:09:58 -0700 (PDT)
- Subject: setting of initial bottom of stack variable in pthread.c (again)
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=ZHZZ442yeArZ1qQXDqnIBvW999wywKExZR9XB1oBQDo1USuZy/QVPNtIu3UtBO4g0/c3ZoVe2HYpq18ZwvxOOfmNnCvGSaf4OhDooFGge+aiwfylAiFKlom1iAmlZHmiRSXGHSDePJ8EvtPuUGG+jAvaxz6tnqRTQBpiTF7btno= ;
I posted this on the alpha mailing list, but this
might be a better place for it. From what I
understand, when __pthread_initial_thread_bos is set
in pthread.c, it must be set to cover both the initial
thread and manager thread. Looking at the
STACK_GROWS_DOWN case, it looks like this variable is
set to STACK_SIZE beyond the space it needs to to
cover the initial and manager thread. Graphically:
------------------- top of initial stack
| Initial thread |
| |
-------------------
| Manager thread |
| |
-------------------
| Free space |
| |
------------------- __pthread_initial_thread_bos
When the very first worker thread gets assigned its
stack space it is getting assigned the space in free
space which is above __pthread_initial_thread_bos
(instead of something below
__pthread_initial_thread_bos as it should since it is
not part of the initial thread), so when thread_self
is called from the first worker thread, thread_self
returns the initial thread, not the worker thread.
All other threads created after the first worker
thread are assigned memory below
__pthread_initial_thread_bos. The line that sets
__pthread_initial_thread_bos is
__pthread_initial_thread_bos =
(char *)(((long)CURRENT_STACK_FRAME - 2 *
STACK_SIZE) & ~(STACK_SIZE - 1));
Changing the 2 in the above equation to a 1 would
solve the problem of __pthread_initial_thread_bos
being set beyond the free space depicted above. Is
what is depicted above correct and it's a problem with
the memory the kernel is handing out, or is this a
bug, and the 2 should be a 1 since the stack is
growing down?
Thanks
Jay
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com