Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 293527

Summary: <sys-libs/glibc-2.11.1 has a race in free() with malloc checking enabled
Product: Gentoo Linux Reporter: Togge <togge.gentoo>
Component: [OLD] Core systemAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal CC: axiator, betelgeuse, cyp561, daggs, deduktionstheorem, esigra, holger, ppurka, tampakrap
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: http://sourceware.org/bugzilla/show_bug.cgi?id=10282
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 289342    

Description Togge 2009-11-17 18:39:04 UTC
glibc versions prior to 2.11.1 that has the new MALLOC_CHECK feature has a race condition in free().

For the upstream applied fix please see: http://sourceware.org/bugzilla/show_bug.cgi?id=10282

Reproducible: Always

Steps to Reproduce:
Test program:

/* compile with -fopenmp */
#include <stdlib.h>
#include <unistd.h>

int main(void)
{
#pragma omp parallel num_threads(256)
  while (1) {
    void *ptr = malloc(rand() % 65536);
    usleep((rand() % 100) * 100);
    free(ptr);
    usleep((rand() % 100) * 100);
  }
  return 0;
}
Comment 1 Vlastimil Babka (Caster) (RETIRED) gentoo-dev 2009-11-17 22:09:55 UTC
*** Bug 293552 has been marked as a duplicate of this bug. ***
Comment 2 SpanKY gentoo-dev 2009-11-18 03:54:14 UTC
this isnt a critical issue if it only occurs when malloc checking is enabled
Comment 3 Brian K. 2009-11-18 04:06:11 UTC
(In reply to comment #2)
> this isnt a critical issue if it only occurs when malloc checking is enabled
> 

I believe malloc checking is enabled by default though.
Comment 4 SpanKY gentoo-dev 2009-11-18 05:11:52 UTC
i dont think so ... the code does:
  s = getenv("MALLOC_CHECK_");
  if(s && s[0]) {
    mALLOPt(M_CHECK_ACTION, (int)(s[0] - '0'));
    if (check_action != 0)
      __malloc_check_init();
  }

if MALLOC_CHECK_ isnt set in the environment (which nowhere in Gentoo does that), then the racy code isnt executed
Comment 5 Togge 2009-11-18 09:59:35 UTC
Well some how it is being run, I am hit by this bug everytime I start qt creator or kdevelop. Others report that it affects them on every time they use multimedia players. Could it be that the env var is being set by individual packages and that this then pollutes the environment?
Comment 6 Togge 2009-11-18 11:53:56 UTC
Sorry about the spam did not intend to change back to critical.
Comment 7 Brian K. 2009-11-18 12:07:04 UTC
(In reply to comment #5)
> Well some how it is being run, I am hit by this bug everytime I start qt
> creator or kdevelop. Others report that it affects them on every time they use
> multimedia players. Could it be that the env var is being set by individual
> packages and that this then pollutes the environment?
> 

If your using a development version of kde it should be getting set by startkde. Thats how I'm hitting it here.
Comment 8 Theo Chatzimichos (RETIRED) archtester gentoo-dev Security 2009-11-20 18:46:57 UTC
I added the patch to kde-testing overlay, in masked sys-libs/glibc-2.11-r1, since this bug affects mostly the KDE development versions (snapshots and live ebuilds). We expect a new glibc in the end of the month, i guess there is no need to move it to tree and cause upgrade again and again to so many users.
Comment 9 SpanKY gentoo-dev 2009-11-21 06:21:47 UTC
there's no need to create your own ebuilds.  just put the patches you want into the normal /etc/portage/patches/ dir.

added the patch to the 2.10 and 2.11 queues
Comment 10 SpanKY gentoo-dev 2009-12-17 21:29:31 UTC
*** Bug 297319 has been marked as a duplicate of this bug. ***
Comment 11 SpanKY gentoo-dev 2009-12-29 06:52:55 UTC
*** Bug 298375 has been marked as a duplicate of this bug. ***
Comment 12 DaggyStyle 2010-01-05 15:25:18 UTC
(In reply to comment #9)
> there's no need to create your own ebuilds.  just put the patches you want into
> the normal /etc/portage/patches/ dir.
> 
> added the patch to the 2.10 and 2.11 queues
> 

where can one find that patch?
this problem causes my nerves to spike...

Comment 13 SpanKY gentoo-dev 2010-01-29 20:33:41 UTC
*** Bug 298375 has been marked as a duplicate of this bug. ***
Comment 14 DaggyStyle 2010-01-30 21:40:54 UTC
ok, assuming that the patch exists, it doesn't solve the issue, I have the same problem with kdevelop from svn.