diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-07-20 06:38:12 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-07-20 06:38:12 -0700 |
commit | 6f7e3aa0e70b85b8d78b8dcaaed92cd376378ece (patch) | |
tree | c7d52dd9cd1334db1210aecd3e70df7515f9ee38 /buf.h | |
parent | ed7185e3fd6307d9c4bc97be606a08bd9ed3502f (diff) | |
download | txr-6f7e3aa0e70b85b8d78b8dcaaed92cd376378ece.tar.gz txr-6f7e3aa0e70b85b8d78b8dcaaed92cd376378ece.tar.bz2 txr-6f7e3aa0e70b85b8d78b8dcaaed92cd376378ece.zip |
hash: revert bad fix in weak processing.
This commit reverts the April 11, 2020 commit
a4c376979d15323ad729e92e41ba43768e8dc163, subject line
"hash: bugfix: spurious retention in weak processing".
That commit is a regression.
This revert requires a follow-up; the commit was trying to
fix an issue which now reappears. It will have to be
fixed differently.
The regression is that in a situation in which data is
referenced through two or more dependent weak tables, entries
that are reachable can spontaneously disappear from downstream
tables.
Suppose H0 and H1 are weak-key tables. Suppose the program
holds a datum K0, which is the only reference through which
D1 is reached, in the following chain:
K0 -> [H0] -> K1 -> [H1] -> D1
K0 is a key in hash table H0, which has weak keys.
The the associated value K1 is a key in H1, which then
references D1. H0 holds the only reference to K1,
and H1 holds the only reference to D1.
During the first GC marking phase, because we do not mark any
part of a table which has weak keys, when we process H0
we do not mark the value K1. Thus K1 looks unreachable.
In the second weak hash processing pass, because K1 was
treated as unreachable, the <K1, D1> entry in H1 is
incorrectly expired.
This issue affects TXR's origin_hash and form_to_ln_hash,
which are in this relationship. The problem was uncovered in
recent tags.tl work, manifesting as a spurious disappearance
of line number info when processing .txr files. The line
number info disappeared for entries which were traced through
the origin_hash via the macro-ancestor function (see the
unexpand function in tags.tl).
* hash.c (hash_mark): Only skip marking tables that have
both weak keys and values. For weak key tables, mark all the
values and vice versa: for weak value tables, mark the keys.
* txr.1: Text resembling original text restored.
Diffstat (limited to 'buf.h')
0 files changed, 0 insertions, 0 deletions