添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

so i recent had a borrow checking problem , and the (very kind) @steffahn recommended that I use the stacker crate instead of trying too manually manage a stack (to which I agree).

but then, after it was solved, I noticed that after calling stacker::maybe_grow , it exited and seemed to suggest that a stack overflow had occurred.

repo is here .

to reproduce:

git clone https://github.com/pro465/rhokell
cd rhokell
echo "exp(s s z(), s s s s s s s s s s s s z())" | cargo r ./examples/peano.rhk

output on my machine (windows 11):

    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target\debug\rhokell.exe .\examples\peano.rhk`
welcome to rhokell v0.1.0!
input `q`, `quit`, or `exit` for exiting the REPL
=> <4096*"s " + "z()">
thread 'main' has overflowed its stack
error: process didn't exit successfully: `target\debug\rhokell.exe .\examples\peano.rhk` (exit code: 0xc00000fd, STATUS_STACK_OVERFLOW)

the only problem is, i do not have any deeply recursive calls after that. in fact, the only thing that happens is it prompts the user for another expression.

fn drop(&mut self) { stacker::maybe_grow(32 * 1024, 1024 * 1024, || { drop(std::mem::take(&mut self.args)); // or maybe just `self.args.clear();` as that’s shorter 😁

(I don’t like how these magic numbers 32 * 1024, 1024 * 1024 are repeated everywhere. Maybe you’ll want your own wrapper function[1] to be more DRY.)

  • For example

    fn with_stacker<R>(f: impl FnOnce() -> R) -> R {
        stacker::maybe_grow(32 * 1024, 1024 * 1024, f)
    
  •