commit fc6da23112019269f798952c365af1a9d5a59938
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Jul 29 19:08:48 2011 +0200
avoid GC segfault/hang/etc: make gnulib's hash module use GC
While commit 0b0c8f73 arranged to free the non-GC'd hash tables, it
was erroneous. That change led to our storing GC-malloc'd provider
names (and other info) in a non-GC'd hash table, which meant that the
garbage collector would collect/free unref'd (as far as it could see)
but still-in-use buffers.
This change reinstates the gnulib-hash.c-patching hack and removes
the now-unnecessary finalizer-hook code that was added by the above
commit.
* bootstrap.conf (avoided_gnulib_modules): Add --avoid=hash-tests.
* gl/lib/hash.c.diff: New file.
* rest.c (destroy_state_postprocessor): Don't free hash tables
explicitly, now that they're all GC'd.
(gc_register_finalizer_ms): Correct stale comment.
bootstrap.conf | 2 ++
gl/lib/hash.c.diff | 13 +++++++++++++
rest.c | 5 +----
3 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/bootstrap.conf b/bootstrap.conf
index 46bfa52..ddebcbb 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -16,10 +16,12 @@
# along with this program. If not, see <
http://www.gnu.org/licenses/>.
# The lock test takes too long for my taste.
+# The hash test would need linking help to get -lgc.
avoided_gnulib_modules='
--avoid=lock-tests
--avoid=dummy
--avoid=fflush-tests
+ --avoid=hash-tests
'
# gnulib modules used by this package.
diff --git a/gl/lib/hash.c.diff b/gl/lib/hash.c.diff
new file mode 100644
index 0000000..517d4e0
--- /dev/null
+++ b/gl/lib/hash.c.diff
@@ -0,0 +1,13 @@
+diff --git a/lib/hash.c b/lib/hash.c
+index f3de2aa..27f080e 100644
+--- a/lib/hash.c
++++ b/lib/hash.c
+@@ -43,6 +43,8 @@
+ # endif
+ #endif
+
++#include "../gc-wrap.h"
++
+ struct hash_entry
+ {
+ void *data;
diff --git a/rest.c b/rest.c
index 11b2971..cd41dd2 100644
--- a/rest.c
+++ b/rest.c
@@ -864,15 +864,12 @@ destroy_state_postprocessor (void *ms_v, void *client_data)
my_state *ms = ms_v;
if (ms->post)
MHD_destroy_post_processor (ms->post);
- if (ms->dict)
- hash_free (ms->dict);
}
/* Tell the garbage collector that when freeing MS, it must invoke
destroy_state_postprocessor(MS). This is required for each ms->post
since they're allocated via MHD_create_post_processor, which is
- in a separate library into which the GC has no view.
- Likewise for ms->dict, ms->query and ms->aquery. */
+ in a separate library into which the GC has no view. */
static void
gc_register_finalizer_ms(void *ms)
{