]> granicus.if.org Git - gc/commitdiff
Fix missing GC_dirty invocation from debug_end_stubborn_change
authorIvan Maidanski <ivmai@mail.ru>
Tue, 8 May 2018 18:04:55 +0000 (21:04 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 8 May 2018 18:09:54 +0000 (21:09 +0300)
GC_debug_end_stubborn_change was no-op unless STUBBORN_ALLOC defined.

* dbg_mlc.c (GC_debug_end_stubborn_change): De-duplicate definition;
remove hhdr local variable.
* dbg_mlc.c [!STUBBORN_ALLOC] (GC_debug_end_stubborn_change): Check
p belongs to GC heap; call GC_end_stubborn_change(GC_base(p)).

dbg_mlc.c

index 306ae94e948de6a7e44af03a131612d85c3b3956..80b1bc9eab9c9add51b5561ccafed057807aa524 100644 (file)
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -640,22 +640,6 @@ STATIC void * GC_debug_generic_malloc(size_t lb, int knd, GC_EXTRA_PARAMS)
     GC_change_stubborn(q);
   }
 
-  GC_API void GC_CALL GC_debug_end_stubborn_change(const void *p)
-  {
-    const void * q = GC_base_C(p);
-    hdr * hhdr;
-
-    if (q == 0) {
-        ABORT_ARG1("GC_debug_end_stubborn_change: bad arg", ": %p", p);
-    }
-    hhdr = HDR(q);
-    if (hhdr -> hb_obj_kind != STUBBORN) {
-        ABORT_ARG1("GC_debug_end_stubborn_change: arg not stubborn",
-                   ": %p", p);
-    }
-    GC_end_stubborn_change(q);
-  }
-
 #else /* !STUBBORN_ALLOC */
 
   GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_stubborn(size_t lb,
@@ -666,11 +650,23 @@ STATIC void * GC_debug_generic_malloc(size_t lb, int knd, GC_EXTRA_PARAMS)
 
   GC_API void GC_CALL GC_debug_change_stubborn(
                                 const void * p GC_ATTR_UNUSED) {}
-
-  GC_API void GC_CALL GC_debug_end_stubborn_change(
-                                const void * p GC_ATTR_UNUSED) {}
 #endif /* !STUBBORN_ALLOC */
 
+GC_API void GC_CALL GC_debug_end_stubborn_change(const void *p)
+{
+    const void * q = GC_base_C(p);
+
+    if (NULL == q) {
+        ABORT_ARG1("GC_debug_end_stubborn_change: bad arg", ": %p", p);
+    }
+# ifdef STUBBORN_ALLOC
+    if (HDR(q) -> hb_obj_kind != STUBBORN)
+        ABORT_ARG1("GC_debug_end_stubborn_change: arg not stubborn",
+                   ": %p", p);
+# endif
+    GC_end_stubborn_change(q);
+}
+
 GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_atomic(size_t lb,
                                                             GC_EXTRA_PARAMS)
 {