Comment #26 on issue 28244 by craig.schlenter: Overriding calloc causes a  
stack overflow in shared build
http://code.google.com/p/chromium/issues/detail?id=28244

The 431025 CL works for me. The NULL approach was also taken in the  
memusage.c URL in
comment 13 IIRC btw.

I've pasted the glibc code below ... it looks like it does deal with NULL  
but perhaps
in a non thread-safe way by using a static buffer (which is arguably what  
the other
proposals do too so those might also not be technically 100% thread safe  
but I
haven't checked in detail).

I have no strong opinions on what is best here - I suspect the user base  
for the
shared build is really small so even if we wait for tcmalloc to be the  
default, I
doubt it will matter too much.

[from dlerror.c]

internal_function
_dlerror_run (void (*operate) (void *), void *args)
{
   struct dl_action_result *result;

   /* If we have not yet initialized the buffer do it now.  */
   __libc_once (once, init);

   /* Get error string and number.  */
   if (static_buf != NULL)
     result = static_buf;
   else
     {
       /* We don't use the static buffer and so we have a key.  Use it
          to get the thread-specific buffer.  */
       result = __libc_getspecific (key);
       if (result == NULL)
         {
           result = (struct dl_action_result *) calloc (1, sizeof (*result));
           if (result == NULL)
             /* We are out of memory.  Since this is no really critical
                situation we carry on by using the global variable.
                This might lead to conflicts between the threads but
                they soon all will have memory problems.  */
             result = &last_result;
           else
             /* Set the tsd.  */
             __libc_setspecific (key, result);
         }
     }
[snip]

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

-- 
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/group/chromium-bugs

Reply via email to