diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-01-06 00:26:31 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-01-06 00:26:31 -0700 |
commit | d84e1581e949ea301db9d9d567edee04b613991e (patch) | |
tree | 16007cc499fd45010ebd56be820fd934ba217cbd | |
parent | cd7671812098bc07ce19e7b1b2b014b44f4ca58f (diff) | |
download | txr-d84e1581e949ea301db9d9d567edee04b613991e.tar.gz txr-d84e1581e949ea301db9d9d567edee04b613991e.tar.bz2 txr-d84e1581e949ea301db9d9d567edee04b613991e.zip |
gc: bug in sub-str on lazy string argument.
This showed up as an intermittent segfault on OpenBSD
of the test case tests/006/freeform-5.txr, reproducible
quite often, around 30% to 60%. This was with gcc 4.2.1.
* lib.c (lazy_sub_str): We need a gc_hint here on the
prefix hend in pfxcopy. The garbage collector is
scavenging that object, not seeing that we planted
it into a malloced structure.
-rw-r--r-- | lib.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -5653,6 +5653,7 @@ static val lazy_sub_str(val lstr, val from, val to) lsub->ls.props = coerce(struct lazy_string_props *, chk_copy_obj(coerce(mem_t *, lstr->ls.props), sizeof *lstr->ls.props)); + gc_hint(pfxcopy); return lsub; } } |