bug-glibc
[Top][All Lists]
Advanced

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

dl-tls.c:_dl_allocate_tls_storage() and memalign


From: Frank Cusack
Subject: dl-tls.c:_dl_allocate_tls_storage() and memalign
Date: Tue, 27 Jan 2004 02:44:14 -0800
User-agent: Gnus/5.090018 (Oort Gnus v0.18) Emacs/21.2 (gnu/linux)

Why does _dl_allocate_tls_storage() call __libc_memalign() and not
memalign()?  I'd like to replace this with memalign() so that a debug
malloc library will work properly.  I'm not sure that this is the
right thing to do, but as is, the glibc-internal memalign() is called,
but a (possibly) external free() is called.  This doesn't work.

The only mention I can find is in ChangeLog.13:

2002-08-04  Roland McGrath  <address@hidden>
        * sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage): Allocate the
        TCB with __libc_memalign instead of mmap.

Here's a diff against 2.3.2:

--- glibc-2.3.2/sysdeps/generic/dl-tls.c.orig   2004-01-27 02:38:04.000000000 
-0800
+++ glibc-2.3.2/sysdeps/generic/dl-tls.c        2004-01-27 02:39:08.000000000 
-0800
@@ -293,7 +293,7 @@
 # endif
 
   /* Allocate a correctly aligned chunk of memory.  */
-  result = __libc_memalign (GL(dl_tls_static_align), size);
+  result = memalign (GL(dl_tls_static_align), size);
   if (__builtin_expect (result != NULL, 0))
     {
       /* Allocate the DTV.  */
@@ -483,7 +483,7 @@
 {
   void *newp;
 
-  newp = __libc_memalign (map->l_tls_align, map->l_tls_blocksize);
+  newp = memalign (map->l_tls_align, map->l_tls_blocksize);
   if (newp == NULL)
     oom ();
 
Comments?  Seems safe to me.  Note that while __libc_memalign() is
used as shown above, malloc(), calloc() and realloc() are used
elsewhere.  __libc_memalign() seems like an oversight.

/fc





reply via email to

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