summaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2010-01-21 07:04:40 -0800
committerKaz Kylheku <kaz@kylheku.com>2010-01-21 07:04:40 -0800
commit64b09cd68e003f3f1c1b71284aceb90b9c236f05 (patch)
treee1828fb20176521872266aebb8d9c3ad3460e0e9 /gc.c
parentbdca6affe8efdbf294e00aea5468ef066c1a031c (diff)
downloadtxr-64b09cd68e003f3f1c1b71284aceb90b9c236f05.tar.gz
txr-64b09cd68e003f3f1c1b71284aceb90b9c236f05.tar.bz2
txr-64b09cd68e003f3f1c1b71284aceb90b9c236f05.zip
Fix for unbounded memory growth problem reproduced with GCC 4.4.1
on 32 bit x86 Fedora. This happens because the lazy list variable ``data'' in the match_files function is optimized to a register, but a stale value of that variable persists in the backing storage.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index 2a659e2b..284ca711 100644
--- a/gc.c
+++ b/gc.c
@@ -486,3 +486,20 @@ void unmark(void)
}
}
}
+
+/*
+ * This function does nothing.
+ * gc_hint(x) just takes the address of local variable x
+ * and passes it to this function. This prevents the compiler
+ * from caching the value across function calls.
+ * This is needed for situations where
+ * - a compiler caches a variable in a register, but not entirely (the variable
+ * has a backing memory location); and
+ * - that location contains a stale old value of the variable, which cannot be
+ * garbage-collected as a result; and
+ * - this causes a problem, like unbounded memory growth.
+ */
+void gc_hint_func(val *val)
+{
+ (void) val;
+}