From 4719749c5b4141bd9950e5fc01241de02ee4864e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 1 Jan 2024 22:10:04 -0800 Subject: iter_begin: gc problem. Also affects seq_begin. * lib.c (seq_begin, iter_begin): We must gc_protect the incoming obj also, not only the iter. Both these pointers are in the seq_info_t structure which is no longer used at the time the iterator is being allocated by the call to cobj, and so may be prematurely garbage collected. --- lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib.c b/lib.c index 0e374c70..b1ce9e9c 100644 --- a/lib.c +++ b/lib.c @@ -1195,6 +1195,7 @@ val seq_begin(val obj) iter = si->ui.iter; si_obj = cobj(coerce(mem_t *, si), seq_iter_cls, &seq_iter_ops); gc_hint(iter); + gc_hint(obj); return si_obj; } @@ -1250,6 +1251,7 @@ val iter_begin(val obj) iter = si->ui.iter; si_obj = cobj(coerce(mem_t *, si), seq_iter_cls, &seq_iter_ops); gc_hint(iter); + gc_hint(obj); return si_obj; } } -- cgit v1.2.3