From d84e1581e949ea301db9d9d567edee04b613991e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 6 Jan 2024 00:26:31 -0700 Subject: 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. --- lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib.c b/lib.c index b1ce9e9c..3a704997 100644 --- a/lib.c +++ b/lib.c @@ -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; } } -- cgit v1.2.3