This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi! In NPTL, getpid, __libc_alloca_cutoff and a bunch of other functions in libc.a access various fields in struct pthread. But on TLS_TCB_AT_TP architectures, libc.a only allocates space for tcbhead_t and TLS area before it (via sbrk), so the rest of struct pthread is available for subsequent e.g. malloc calls. This leads to problems like getpid always returning 5 or 7... TLS_INIT_TCB* is only used in libc-tls.c (this case) and rtld.c (only if ld.so itself uses __thread, which is not the case in any glibc so far). 2005-05-20 Jakub Jelinek <jakub@redhat.com> * sysdeps/i386/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN): Define to size/alignment of struct pthread rather than tcbhead_t. * sysdeps/x86_64/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN): Likewise. * sysdeps/s390/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN): Likewise. * sysdeps/sparc/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN): Likewise. --- libc/nptl/sysdeps/s390/tls.h.jj 2005-05-03 21:50:31.000000000 +0200 +++ libc/nptl/sysdeps/s390/tls.h 2005-05-20 10:57:42.000000000 +0200 @@ -81,11 +81,13 @@ typedef struct /* Get the thread descriptor definition. */ # include <nptl/descr.h> -/* This is the size of the initial TCB. */ -# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t) +/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t), + because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole + struct pthread even when not linked with -lpthread. */ +# define TLS_INIT_TCB_SIZE sizeof (struct pthread) /* Alignment requirements for the initial TCB. */ -# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) +# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread) /* This is the size of the TCB. */ # define TLS_TCB_SIZE sizeof (struct pthread) --- libc/nptl/sysdeps/sparc/tls.h.jj 2005-05-03 21:50:32.000000000 +0200 +++ libc/nptl/sysdeps/sparc/tls.h 2005-05-20 10:56:32.000000000 +0200 @@ -69,11 +69,13 @@ typedef struct register struct pthread *__thread_self __asm__("%g7"); -/* This is the size of the initial TCB. */ -# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t) +/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t), + because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole + struct pthread even when not linked with -lpthread. */ +# define TLS_INIT_TCB_SIZE sizeof (struct pthread) /* Alignment requirements for the initial TCB. */ -# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) +# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread) /* This is the size of the TCB. */ # define TLS_TCB_SIZE sizeof (struct pthread) --- libc/nptl/sysdeps/i386/tls.h.jj 2005-05-03 21:50:30.000000000 +0200 +++ libc/nptl/sysdeps/i386/tls.h 2005-05-20 10:55:13.000000000 +0200 @@ -1,5 +1,5 @@ /* Definition for thread-local data handling. nptl/i386 version. - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -102,11 +102,13 @@ union user_desc_init /* Get the thread descriptor definition. */ # include <nptl/descr.h> -/* This is the size of the initial TCB. */ -# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t) +/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t), + because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole + struct pthread even when not linked with -lpthread. */ +# define TLS_INIT_TCB_SIZE sizeof (struct pthread) /* Alignment requirements for the initial TCB. */ -# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) +# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread) /* This is the size of the TCB. */ # define TLS_TCB_SIZE sizeof (struct pthread) --- libc/nptl/sysdeps/x86_64/tls.h.jj 2005-05-03 21:50:35.000000000 +0200 +++ libc/nptl/sysdeps/x86_64/tls.h 2005-05-20 10:56:05.000000000 +0200 @@ -1,5 +1,5 @@ /* Definition for thread-local data handling. nptl/x86_64 version. - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -82,11 +82,13 @@ typedef struct # endif #endif -/* This is the size of the initial TCB. */ -# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t) +/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t), + because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole + struct pthread even when not linked with -lpthread. */ +# define TLS_INIT_TCB_SIZE sizeof (struct pthread) /* Alignment requirements for the initial TCB. */ -# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) +# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread) /* This is the size of the TCB. */ # define TLS_TCB_SIZE sizeof (struct pthread) Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |