blueszhangsh / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

TCMalloc: Dies at startup with error on mmap region count #164

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
*** What steps will reproduce the problem?

1. Run TCMalloc with glibc that repeatedly allocates AND frees mmap regions
before main.

*** What is the expected output? What do you see instead?

The following check fires:

memory_region_map.cc:432:    RAW_CHECK(saved_regions_count <
arraysize(saved_regions), "");

*** What version of the product are you using? On what operating system?

All versions of gperftools 0.99-1.3, on fc4.

*** Please provide any additional information below.

The problem is that at static initialization time, some of our libc
functions repeatedly map and unmap memory regions which count as a
"recursive" map/unmap for the sake of the "hacky" (adjective taken from
comment in source :P) code in memory_region_map.cc.  Unfortunately, in the
hacky code, regions which are unmapped recursively are _NOT_ taken out of
the temporary array of size 10 (saved_regions[]) until the whole recursive
call is over, so we run out of temporary region space.

The provided patch removes regions immediately from the saved_regions[]
array if the region passed to an unmap() call _exactly_ matches an earlier
mmap() call (both low & high boundaries match).

We have been using this patch for months in production and it works great.

Note that we run with libunwind-0.99 on x86-64. 

Original issue reported on code.google.com by mrab...@gmail.com on 22 Aug 2009 at 8:45

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch -- I'll ask the code author about applying it.

One question I have: given that the 'if (recursive_insert)' block always does a
return at the end, do you really need the 'if (!recursive_insert) added to the
following call to HandleSavedRegionsLocked (that you added)?

Original comment by csilv...@gmail.com on 24 Aug 2009 at 5:01

GoogleCodeExporter commented 9 years ago
i need it.  the previous block is:

  if (regions_ == NULL) {
    if (recursive_insert) {
      ...
    }
    ...
    return;
  }

Thus, we do not hit the return when the situation is (regions_ != NULL &&
recursive_insert)

Original comment by mrab...@gmail.com on 24 Aug 2009 at 10:26

GoogleCodeExporter commented 9 years ago
This fix is in perftools 1.4, just released.

Original comment by csilv...@gmail.com on 11 Sep 2009 at 6:59