summaryrefslogtreecommitdiff
path: root/alloc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-02-23 18:33:45 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-02-23 18:33:45 +0300
commitb82d4a16b60c38584cf238cbaf7f98549865d8cb (patch)
tree04e575c5fa558c85fcdb1dcf39850da79e3616ce /alloc.c
parentd93875239734b39fc840c468fbb620551186468c (diff)
downloadbdwgc-b82d4a16b60c38584cf238cbaf7f98549865d8cb.tar.gz
Warn if heap has grown while GC was disabled
* alloc.c (GC_expand_hp): Increment GC_heapsize_on_gc_disable by the corresponding size if GC disabled and the heap is expanded. * include/private/gc_priv.h (GC_arrays._heapsize_on_gc_disable): Declare field. * misc.c (GC_enable): Call WARN with the appropriate message if going from GC disabled to enabled mode and the heap size is greater than GC_heapsize_on_gc_disable. * misc.c (GC_disable): Store the current heap size value to GC_heapsize_on_gc_disable if going from GC enabled to disabled mode.
Diffstat (limited to 'alloc.c')
-rw-r--r--alloc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/alloc.c b/alloc.c
index 632213df..1d4fbcb5 100644
--- a/alloc.c
+++ b/alloc.c
@@ -1608,7 +1608,13 @@ GC_API int GC_CALL GC_expand_hp(size_t bytes)
if (!EXPECT(GC_is_initialized, TRUE)) GC_init();
LOCK();
result = GC_expand_hp_inner(n_blocks);
- if (result) GC_requested_heapsize += bytes;
+ if (result) {
+ GC_requested_heapsize += bytes;
+ if (GC_dont_gc) {
+ /* Do not call WARN if the heap growth is intentional. */
+ GC_heapsize_on_gc_disable += n_blocks * HBLKSIZE;
+ }
+ }
UNLOCK();
return (int)result;
}