Tables with __tostring
metamethods lead to infinite yield
#273
Labels
enhancement
New feature or request
__tostring
metamethods lead to infinite yield
#273
Summary
With tables that have a
__tostring
metamethod that invokesstdio.format
, a mutex deadlock within the formatter is triggered, causing an infinite yield.Minimal Reproduction
Root Cause
This behavior occurs due to the mutex guard here:
lune/crates/lune-utils/src/fmt/value/mod.rs
Line 51 in c935149
This guard exists to prevent sudden changes in global coloring configuration in the
console
crate, which can cause unexpected coloring behavior.The print method calls the formatter, which calls a
__tostring
implementation if present, and the metamethod callsstdio.format
again -- bam! Infinite recursion.Potential Fixes
Mutex
with anRwLock
and prevent this deadlockconsole-rs
to make color configuration non-globalThe text was updated successfully, but these errors were encountered: