You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::marker::PhantomData;use gc_arena::{rootless_arena,Collect,Gc};#[derive(Collect)]#[collect(no_drop)]enumA<'gc>{V(Vec<A<'gc>>),Bar(PhantomData<&'gc()>),}fnmain(){rootless_arena(|mc| drop(Gc::new(mc,A::Bar(PhantomData))));}
This causes a stack overflow for me. It seems to have something to do with the impl Collect for Collections, that seems to trigger an infinite loop. It works with every Collection that has indirection and the Collect::needs_trace is T::needs_trace().
The text was updated successfully, but these errors were encountered:
Yep, this definitely sounds like a bug in the released version of gc-arena. This can be worked around by manually implementing Collect for your type.
In the master branch right now, the bug still sort of exists but it is much less harmful because it fails at compile time, since Collect::NEEDS_TRACE is now an associated constant (it fails for me with something like cycle detected when elaborating drops for ...).
In the master branch (and also possibly the released version) this can also be worked around for types that actually contain Gc pointers by changing the ordering of fields / variants such that NEEDS_TRACE is set to true || <some other expression>, short-cutting the failure. If the type doesn't actually contain any Gc pointers then this will never work, but in that case usually you can get around the problem entirely with #[collect(require_static)] (not in your example because it is non-'static, but I assume this is artificial and only to demonstrate the problem).
What we could do to cover every case without requiring the user to re-order fields or variants is allow you to set #[collect(always_needs_trace)] which could replace the generated expression for NEEDS_TRACE with just true, which is always safe to do (but may be less efficient). This is still confusing and not entirely ideal, but I can't think of a better solution right now.
This causes a stack overflow for me. It seems to have something to do with the
impl Collect
for Collections, that seems to trigger an infinite loop. It works with every Collection that has indirection and theCollect::needs_trace
isT::needs_trace()
.The text was updated successfully, but these errors were encountered: