rune-rs/rune

`tracing::instrument` on `op_return_internal` is broken

tgolsson opened this issue · 1 comments

Noticed this when upping the log-level on an old project. If the return value doesn't have Protocol::DEBUG_STRING it'll just hard-crash when the return happens. Took quite a while to figure out why... :D

#[inline]
#[tracing::instrument(skip(self))]
fn op_return_internal(&mut self, return_value: Value) -> Result<bool, VmErrorKind> {
let exit = self.pop_call_frame()?;
self.stack.push(return_value)?;
Ok(exit)
}

I can point-fix it, but I think in general it'd be nicer if dbg! etc was less prone to exploding. Maybe an optional feature to "fall back" to something like <%T object at %p>, which isn't what most people would want but won't lead to spurious BOOM.

Gaddangit! Well, I suppose we should add a fallible default debug impl than is used by default by Rust.

It should mostly be a matter of handling the error from the existing implementation.