[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19180: Weak tables harmful to GC?
From: |
Ludovic Courtès |
Subject: |
bug#19180: Weak tables harmful to GC? |
Date: |
Mon, 30 Oct 2017 13:35:56 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Hi Ricardo,
Ricardo Wurmus <address@hidden> skribis:
> In language/tree-il/analyze.scm:
> 1053:33 3 Exception thrown while printing backtrace:
> ERROR: In procedure assq: Wrong type argument in position 2 (expecting
> association list): ((system base pmatch) car . #f)
>
> ice-9/boot-9.scm:760:25: In procedure dispatch-exception:
> ice-9/boot-9.scm:760:25: In procedure assq: Wrong type argument in position 2
> (expecting association list): ((system base pmatch) car . #f)
It’s a sign that the weak tables were too weak, this time. :-)
The problem stems from the fact that weak pairs were initialized too
late. Thus, the first calls to ‘scm_weak_car_pair’ were happening
before the weak-car pair GC descriptor had been initialized; they were
therefore using 0 as their descriptor, and ended up not being traced at
all by the GC.
The fix is to initialize weak pairs before symbols, as in 2.0:
modified libguile/hashtab.c
@@ -1608,10 +1608,11 @@ scm_c_weak_table_fold (scm_t_hash_fold_fn fn, void
*closure,
+/* Initialize weak pairs, used by weak hash tables. This needs to be
+ done early on because it's used by interned symbols etc. */
void
-scm_init_hashtab ()
+scm_init_weak_pairs ()
{
- /* Initialize weak pairs. */
GC_word wcar_pair_bitmap[GC_BITMAP_SIZE (scm_t_cell)] = { 0 };
GC_word wcdr_pair_bitmap[GC_BITMAP_SIZE (scm_t_cell)] = { 0 };
@@ -1627,6 +1628,11 @@ scm_init_hashtab ()
wcdr_pair_descr = GC_make_descriptor (wcdr_pair_bitmap,
GC_WORD_LEN (scm_t_cell));
+}
+
+void
+scm_init_hashtab ()
+{
#include "libguile/hashtab.x"
}
modified libguile/hashtab.h
@@ -174,6 +174,7 @@ SCM_API SCM scm_hash_map_to_list (SCM proc, SCM hash);
SCM_API SCM scm_hash_count (SCM hash, SCM pred);
SCM_INTERNAL void scm_i_hashtable_print (SCM exp, SCM port, scm_print_state
*pstate);
SCM_INTERNAL void scm_init_hashtab (void);
+SCM_INTERNAL void scm_init_weak_pairs (void);
/* Guile 2.2.x (x <= 2) weak-table API. */
modified libguile/init.c
@@ -390,7 +390,8 @@ scm_i_init_guile (void *base)
#ifdef GUILE_DEBUG_MALLOC
scm_debug_malloc_prehistory ();
#endif
- scm_symbols_prehistory (); /* requires weak_table_prehistory */
+ scm_init_weak_pairs ();
+ scm_symbols_prehistory (); /* requires weak_pairs */
scm_modules_prehistory ();
scm_init_array_handle ();
I’m attaching updated patches. I’ve let the Guix build run to
completion this time. Let me know if it works for you!
Ludo’.
0001-Remove-weak-tables-and-revert-to-weak-hash-tables.patch
Description: Text Data
0002-Keep-weak-hash-table-item-count-consistent.patch
Description: Text Data
- bug#19180: Weak tables harmful to GC?, Christopher Allan Webber, 2017/10/24
- bug#19180: Weak tables harmful to GC?, Ricardo Wurmus, 2017/10/25
- bug#19180: Weak tables harmful to GC?, Ludovic Courtès, 2017/10/26
- bug#19180: Weak tables harmful to GC?, Ricardo Wurmus, 2017/10/26
- bug#19180: Weak tables harmful to GC?, Ricardo Wurmus, 2017/10/26
- bug#19180: Weak tables harmful to GC?, Ludovic Courtès, 2017/10/27
- bug#19180: Weak tables harmful to GC?, Ricardo Wurmus, 2017/10/28
- bug#19180: Weak tables harmful to GC?,
Ludovic Courtès <=
- bug#19180: Weak tables harmful to GC?, Ricardo Wurmus, 2017/10/30
- bug#19180: Weak tables harmful to GC?, Ricardo Wurmus, 2017/10/30
- bug#19180: Weak tables harmful to GC?, Ludovic Courtès, 2017/10/30
- bug#19180: Weak tables harmful to GC?, Andy Wingo, 2017/10/30
- bug#19180: Weak tables harmful to GC?, Ludovic Courtès, 2017/10/30
- bug#19180: Weak tables harmful to GC?, Andy Wingo, 2017/10/31
- bug#19180: Weak tables harmful to GC?, Ludovic Courtès, 2017/10/31
- bug#19180: Weak tables harmful to GC?, Ludovic Courtès, 2017/10/26