Open twisted-pear opened 7 years ago
So from what I can tell the problem is that we always use the fmt::Debug
on Node
, so we call that for every node in the tree and that in turn calls the same function for every subtree and so we overflow the stack.
My proposed fix is in the fmt_fix branch. I removed the fmt::Debug
on Node
and replaced it with a derive(Debug)
so we use the debug on LeafRepr
and BranchNode
as needed.
I have no idea if this is correct or breaks something else but the tests make it through. I also added some tests that would trigger this bug.
@twisted-pear that sounds good, yeah. I had initially written a custom fmt::Debug
implementation rather than deriving, since the derived format was a little too wordy, but deriving is fine. I suspect making the custom fmt::Debug
implementation #[inline]
would also fix this?
I checked out your branch and it looks good to merge; with that said, before we close this issue we should make sure this is definitely localised to only the fmt::Debug
implementation - I'm pretty sure you're right but we ought to throw together some tests just to be on the safe side?
So I noticed that a test like
fails with
. I also don't get a backtrace. I tracked the Problem down to something like this
panic ! ("whatever: {:?}", r);
, which is done whenassert_eq!
fails. Thispanic
will produce the same error message. I'm assuming that we somehow overflow the stack when building thefmt::Debug
message but I don't know where yet.