]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/glibc/glibc-rh789238.patch
Merge remote-tracking branch 'origin/next' into thirteen
[people/teissler/ipfire-2.x.git] / src / patches / glibc / glibc-rh789238.patch
1 diff -rup a/malloc/malloc.c b/malloc/malloc.c
2 --- a/malloc/malloc.c 2012-02-13 21:46:11.678847531 -0700
3 +++ b/malloc/malloc.c 2012-02-13 22:43:14.788431976 -0700
4 @@ -3669,8 +3669,9 @@ public_mALLOc(size_t bytes)
5 } else {
6 #if USE_ARENAS
7 /* ... or sbrk() has failed and there is still a chance to mmap() */
8 - ar_ptr = arena_get2(ar_ptr->next ? ar_ptr : 0, bytes);
9 - (void)mutex_unlock(&main_arena.mutex);
10 + mstate prev = ar_ptr->next ? ar_ptr : 0;
11 + (void)mutex_unlock(&ar_ptr->mutex);
12 + ar_ptr = arena_get2(prev, bytes);
13 if(ar_ptr) {
14 victim = _int_malloc(ar_ptr, bytes);
15 (void)mutex_unlock(&ar_ptr->mutex);
16 @@ -3929,10 +3930,10 @@ public_vALLOc(size_t bytes)
17 if(!ar_ptr)
18 return 0;
19 p = _int_valloc(ar_ptr, bytes);
20 - (void)mutex_unlock(&ar_ptr->mutex);
21 if(!p) {
22 /* Maybe the failure is due to running out of mmapped areas. */
23 if(ar_ptr != &main_arena) {
24 + (void)mutex_unlock(&ar_ptr->mutex);
25 ar_ptr = &main_arena;
26 (void)mutex_lock(&ar_ptr->mutex);
27 p = _int_memalign(ar_ptr, pagesz, bytes);
28 @@ -3940,14 +3941,17 @@ public_vALLOc(size_t bytes)
29 } else {
30 #if USE_ARENAS
31 /* ... or sbrk() has failed and there is still a chance to mmap() */
32 - ar_ptr = arena_get2(ar_ptr->next ? ar_ptr : 0, bytes);
33 + mstate prev = ar_ptr->next ? ar_ptr : 0;
34 + (void)mutex_unlock(&ar_ptr->mutex);
35 + ar_ptr = arena_get2(prev, bytes);
36 if(ar_ptr) {
37 p = _int_memalign(ar_ptr, pagesz, bytes);
38 (void)mutex_unlock(&ar_ptr->mutex);
39 }
40 #endif
41 }
42 - }
43 + } else
44 + (void)mutex_unlock(&ar_ptr->mutex);
45 assert(!p || chunk_is_mmapped(mem2chunk(p)) ||
46 ar_ptr == arena_for_chunk(mem2chunk(p)));
47
48 @@ -3975,10 +3979,10 @@ public_pVALLOc(size_t bytes)
49
50 arena_get(ar_ptr, bytes + 2*pagesz + MINSIZE);
51 p = _int_pvalloc(ar_ptr, bytes);
52 - (void)mutex_unlock(&ar_ptr->mutex);
53 if(!p) {
54 /* Maybe the failure is due to running out of mmapped areas. */
55 if(ar_ptr != &main_arena) {
56 + (void)mutex_unlock(&ar_ptr->mutex);
57 ar_ptr = &main_arena;
58 (void)mutex_lock(&ar_ptr->mutex);
59 p = _int_memalign(ar_ptr, pagesz, rounded_bytes);
60 @@ -3986,15 +3990,17 @@ public_pVALLOc(size_t bytes)
61 } else {
62 #if USE_ARENAS
63 /* ... or sbrk() has failed and there is still a chance to mmap() */
64 - ar_ptr = arena_get2(ar_ptr->next ? ar_ptr : 0,
65 - bytes + 2*pagesz + MINSIZE);
66 + mstate prev = ar_ptr->next ? ar_ptr : 0;
67 + (void)mutex_unlock(&ar_ptr->mutex);
68 + ar_ptr = arena_get2(prev, bytes + 2*pagesz + MINSIZE);
69 if(ar_ptr) {
70 p = _int_memalign(ar_ptr, pagesz, rounded_bytes);
71 (void)mutex_unlock(&ar_ptr->mutex);
72 }
73 #endif
74 }
75 - }
76 + } else
77 + (void)mutex_unlock(&ar_ptr->mutex);
78 assert(!p || chunk_is_mmapped(mem2chunk(p)) ||
79 ar_ptr == arena_for_chunk(mem2chunk(p)));
80
81 @@ -4064,8 +4070,6 @@ public_cALLOc(size_t n, size_t elem_size
82 #endif
83 mem = _int_malloc(av, sz);
84
85 - /* Only clearing follows, so we can unlock early. */
86 - (void)mutex_unlock(&av->mutex);
87
88 assert(!mem || chunk_is_mmapped(mem2chunk(mem)) ||
89 av == arena_for_chunk(mem2chunk(mem)));
90 @@ -4073,15 +4077,16 @@ public_cALLOc(size_t n, size_t elem_size
91 if (mem == 0) {
92 /* Maybe the failure is due to running out of mmapped areas. */
93 if(av != &main_arena) {
94 + (void)mutex_unlock(&av->mutex);
95 (void)mutex_lock(&main_arena.mutex);
96 mem = _int_malloc(&main_arena, sz);
97 (void)mutex_unlock(&main_arena.mutex);
98 } else {
99 #if USE_ARENAS
100 /* ... or sbrk() has failed and there is still a chance to mmap() */
101 - (void)mutex_lock(&main_arena.mutex);
102 - av = arena_get2(av->next ? av : 0, sz);
103 - (void)mutex_unlock(&main_arena.mutex);
104 + mstate prev = av->next ? av : 0;
105 + (void)mutex_unlock(&av->mutex);
106 + av = arena_get2(prev, sz);
107 if(av) {
108 mem = _int_malloc(av, sz);
109 (void)mutex_unlock(&av->mutex);
110 @@ -4089,7 +4094,8 @@ public_cALLOc(size_t n, size_t elem_size
111 #endif
112 }
113 if (mem == 0) return 0;
114 - }
115 + } else
116 + (void)mutex_unlock(&av->mutex);
117 p = mem2chunk(mem);
118
119 /* Two optional cases in which clearing not necessary */