On Tue 04 Feb 2025 at 08:17 -0400, David Bremner wrote: > Lars Kotthoff <[email protected]> writes: > >> Here's some minimal code to illustrate the problem: >> >> >> import notmuch2 >> >> db = notmuch2.Database() >> >> # this works >> msgs = db.messages("date:today") >> for msg in msgs: >> print(msg.messageid) >> >> # this doesn't segfault, but prints truncated IDs >> msgs = [m for m in db.messages("date:today") if m.messageid] >> print(len(msgs)) >> for msg in msgs: >> print(msg.messageid) >> >> # this segfaults >> msgs = list(db.messages("date:today")) >> print(len(msgs)) >> for msg in msgs: >> print(msg.messageid) > > Hi Floris; > > Any idea what is going on with these iterators?
Hum, it seems *all* iterators are destroyed too early? I think it is just luck that this works for threads, also the 2nd for loop in the above code seems like just luck. (FWIW I get a SIGABRT instead of SIGSEGV from these.) Try removing the `self.destroy()` line from `_base.NotmuchIter.__next__()`. I'm not sure why that destroy was ever there, I think it is a bug to call free on the iterator so early. I can do a proper patch in the next few days probably if no one beats me to it. Haven't looked at the .first and .last issue yet. Cheers, Floris _______________________________________________ notmuch mailing list -- [email protected] To unsubscribe send an email to [email protected]
