summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-01-06 00:26:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2024-01-06 00:26:31 -0700
commita0ab563c96bb9b96bce3c5f24af71b821bacdfde (patch)
tree16007cc499fd45010ebd56be820fd934ba217cbd
parent85ad83cfc0b14f8e1da5b2f7a3bc1086a19514f1 (diff)
downloadtxr-a0ab563c96bb9b96bce3c5f24af71b821bacdfde.tar.gz
txr-a0ab563c96bb9b96bce3c5f24af71b821bacdfde.tar.bz2
txr-a0ab563c96bb9b96bce3c5f24af71b821bacdfde.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.c1
1 files changed, 1 insertions, 0 deletions
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;
}
}