recalculated straight after. But in the case where it's called directly
from alloc_mark_stack, it isn't. If the mark stack gets very large,
this can cause GC_should_collect to always return true, and
GC_alloc_large to get stuck in a loop calling GC_collect_or_expand.
phdr -> hb_flags = 0;
GC_freehblk(p);
GC_heapsize += bytes;
+
+ /* Normally the caller calculates a new GC_collect_at_heapsize,
+ * but this is also called directly from alloc_mark_stack, so
+ * adjust here. It will be recalculated when called from
+ * GC_expand_hp_inner.
+ */
+ GC_collect_at_heapsize += bytes;
+ if (GC_collect_at_heapsize < GC_heapsize /* wrapped */)
+ GC_collect_at_heapsize = (word)(-1);
+
if ((word)p <= (word)GC_least_plausible_heap_addr
|| GC_least_plausible_heap_addr == 0) {
GC_least_plausible_heap_addr = (void *)((ptr_t)p - sizeof(word));