|
|
f686d7 |
From 62536afb90ebb3d7421485c018abd90ba72b919c Mon Sep 17 00:00:00 2001
|
|
|
f686d7 |
From: "Barton E. Schaefer" <schaefer@zsh.org>
|
|
|
f686d7 |
Date: Sat, 18 Jan 2014 21:22:11 -0800
|
|
|
f686d7 |
Subject: [PATCH 1/2] 32285: restart the fheap search in freeheap if the
|
|
|
f686d7 |
current fheap arena is about to be discarded; fixes crash
|
|
|
f686d7 |
|
|
|
f686d7 |
Upstream-commit: 23f98c3e1d4792e32c616e1f73c383988bd86a9c
|
|
|
f686d7 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
f686d7 |
---
|
|
|
f686d7 |
Src/mem.c | 9 +++++++++
|
|
|
f686d7 |
1 file changed, 9 insertions(+)
|
|
|
f686d7 |
|
|
|
f686d7 |
diff --git a/Src/mem.c b/Src/mem.c
|
|
|
f686d7 |
index aeca3d9..eb5a091 100644
|
|
|
f686d7 |
--- a/Src/mem.c
|
|
|
f686d7 |
+++ b/Src/mem.c
|
|
|
f686d7 |
@@ -367,6 +367,15 @@ freeheap(void)
|
|
|
f686d7 |
}
|
|
|
f686d7 |
#endif
|
|
|
f686d7 |
} else {
|
|
|
f686d7 |
+ if (h == fheap && h != heaps) {
|
|
|
f686d7 |
+ /*
|
|
|
f686d7 |
+ * When deallocating the last arena with free space,
|
|
|
f686d7 |
+ * loop back through the list to find another one.
|
|
|
f686d7 |
+ */
|
|
|
f686d7 |
+ fheap = NULL;
|
|
|
f686d7 |
+ hn = heaps;
|
|
|
f686d7 |
+ continue;
|
|
|
f686d7 |
+ }
|
|
|
f686d7 |
#ifdef USE_MMAP
|
|
|
f686d7 |
munmap((void *) h, h->size);
|
|
|
f686d7 |
#else
|
|
|
f686d7 |
--
|
|
|
f686d7 |
2.13.5
|
|
|
f686d7 |
|
|
|
f686d7 |
|
|
|
f686d7 |
From d968fe1061acabd72465a276c2de060f0f8bb668 Mon Sep 17 00:00:00 2001
|
|
|
f686d7 |
From: "Barton E. Schaefer" <schaefer@zsh.org>
|
|
|
f686d7 |
Date: Wed, 22 Jan 2014 21:47:29 -0800
|
|
|
f686d7 |
Subject: [PATCH 2/2] unposted: reformulate 32285 to lift the fheap->sp test
|
|
|
f686d7 |
out of the loop, improve commentary
|
|
|
f686d7 |
|
|
|
f686d7 |
Upstream-commit: 6c603a412751c810ba04bcd463cd3595091ca391
|
|
|
f686d7 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
f686d7 |
---
|
|
|
f686d7 |
Src/mem.c | 24 +++++++++---------------
|
|
|
f686d7 |
1 file changed, 9 insertions(+), 15 deletions(-)
|
|
|
f686d7 |
|
|
|
f686d7 |
diff --git a/Src/mem.c b/Src/mem.c
|
|
|
f686d7 |
index eb5a091..3a7e31d 100644
|
|
|
f686d7 |
--- a/Src/mem.c
|
|
|
f686d7 |
+++ b/Src/mem.c
|
|
|
f686d7 |
@@ -319,23 +319,26 @@ freeheap(void)
|
|
|
f686d7 |
h_free++;
|
|
|
f686d7 |
#endif
|
|
|
f686d7 |
|
|
|
f686d7 |
- /* At this point we used to do:
|
|
|
f686d7 |
- fheap = NULL;
|
|
|
f686d7 |
- *
|
|
|
f686d7 |
+ /*
|
|
|
f686d7 |
* When pushheap() is called, it sweeps over the entire heaps list of
|
|
|
f686d7 |
* arenas and marks every one of them with the amount of free space in
|
|
|
f686d7 |
* that arena at that moment. zhalloc() is then allowed to grab bits
|
|
|
f686d7 |
* out of any of those arenas that have free space.
|
|
|
f686d7 |
*
|
|
|
f686d7 |
- * With the above reset of fheap, the loop below sweeps back over the
|
|
|
f686d7 |
+ * Whenever fheap is NULL here, the loop below sweeps back over the
|
|
|
f686d7 |
* entire heap list again, resetting the free space in every arena to
|
|
|
f686d7 |
* the amount stashed by pushheap() and finding the first arena with
|
|
|
f686d7 |
* free space to optimize zhalloc()'s next search. When there's a lot
|
|
|
f686d7 |
* of stuff already on the heap, this is an enormous amount of work,
|
|
|
f686d7 |
* and performance goes to hell.
|
|
|
f686d7 |
*
|
|
|
f686d7 |
- * However, there doesn't seem to be any reason to reset fheap before
|
|
|
f686d7 |
- * beginning this loop. Either it's already correct, or it has never
|
|
|
f686d7 |
+ * However, if the arena to which fheap points is unused, we want to
|
|
|
f686d7 |
+ * free it, so we have no choice but to do the sweep for a new fheap.
|
|
|
f686d7 |
+ */
|
|
|
f686d7 |
+ if (fheap && !fheap->sp)
|
|
|
f686d7 |
+ fheap = NULL; /* We used to do this unconditionally */
|
|
|
f686d7 |
+ /*
|
|
|
f686d7 |
+ * In other cases, either fheap is already correct, or it has never
|
|
|
f686d7 |
* been set and this loop will do it, or it'll be reset from scratch
|
|
|
f686d7 |
* on the next popheap(). So all that's needed here is to pick up
|
|
|
f686d7 |
* the scan wherever the last pass [or the last popheap()] left off.
|
|
|
f686d7 |
@@ -367,15 +370,6 @@ freeheap(void)
|
|
|
f686d7 |
}
|
|
|
f686d7 |
#endif
|
|
|
f686d7 |
} else {
|
|
|
f686d7 |
- if (h == fheap && h != heaps) {
|
|
|
f686d7 |
- /*
|
|
|
f686d7 |
- * When deallocating the last arena with free space,
|
|
|
f686d7 |
- * loop back through the list to find another one.
|
|
|
f686d7 |
- */
|
|
|
f686d7 |
- fheap = NULL;
|
|
|
f686d7 |
- hn = heaps;
|
|
|
f686d7 |
- continue;
|
|
|
f686d7 |
- }
|
|
|
f686d7 |
#ifdef USE_MMAP
|
|
|
f686d7 |
munmap((void *) h, h->size);
|
|
|
f686d7 |
#else
|
|
|
f686d7 |
--
|
|
|
f686d7 |
2.13.5
|
|
|
f686d7 |
|