]>
Commit | Line | Data |
---|---|---|
bb330e25 AF |
1 | commit 55765a349a96482207fbf927d3666a51878f973b |
2 | Author: Josef Bacik <josef@toxicpanda.com> | |
3 | Date: Wed Aug 19 14:06:56 2015 +0530 | |
4 | ||
5 | Don't fall back to mmap if the original arena is not corrupt | |
6 | ||
7 | The new logic to find an uncontended non-corrupt arena misses a case | |
8 | where the current arena is contended, but is not corrupt. In the | |
9 | degenerate case, this is the only arena. In both cases, the logic | |
10 | falls back to using mmap despite there being an available arena. | |
11 | ||
12 | Attached patch by Josef Bacik makes sure that all arenas are indeed | |
13 | corrupt before falling back to malloc. Verified on x86_64. | |
14 | ||
15 | * malloc/arena.c (reused_arena): return NULL only if all | |
16 | arenas are corrupt. | |
17 | ||
18 | diff --git a/malloc/arena.c b/malloc/arena.c | |
19 | index 21ecc5a1..0424273 100644 | |
20 | --- a/malloc/arena.c | |
21 | +++ b/malloc/arena.c | |
22 | @@ -823,16 +823,21 @@ reused_arena (mstate avoid_arena) | |
23 | ||
24 | /* Make sure that the arena we get is not corrupted. */ | |
25 | mstate begin = result; | |
26 | + bool looped = false; | |
27 | + | |
28 | while (arena_is_corrupt (result)) | |
29 | { | |
30 | result = result->next; | |
31 | if (result == begin) | |
32 | - break; | |
33 | + { | |
34 | + looped = true; | |
35 | + break; | |
36 | + } | |
37 | } | |
38 | ||
39 | /* We could not find any arena that was either not corrupted or not the one | |
40 | we wanted to avoid. */ | |
41 | - if (result == begin) | |
42 | + if (looped) | |
43 | return NULL; | |
44 | ||
45 | /* No arena available without contention. Wait for the next in line. */ |