Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Growable stack #84

Open
loongs-zhang opened this issue Mar 15, 2024 · 2 comments
Open

Growable stack #84

loongs-zhang opened this issue Mar 15, 2024 · 2 comments

Comments

@loongs-zhang
Copy link

maybe_grow in lib.rs, if it becomes full again after expansion, I believe it will receive a SIGBUS/SIGSEGV signal.

Is it possible to increase the stack multiple times in the future?

@nagisa
Copy link
Member

nagisa commented Apr 5, 2024

Yes, you can call maybe_grow recursively for as long as you have memory available.

@loongs-zhang
Copy link
Author

Yes, of course that's possible. What I want to ask is, can it be automatically wrapped? For example, using a macro, as long as the method calls are inside the macro, each method call is converted to be wrapped in maybe_row before making the original call.

original call:

fn call1() {
    // code may cause stack overflow
}
fn call2() {
    call1();
    call1();
    call1();
    ......
    // many times of call1()
}

usage:

// 4096/131072 is just a example
maybe_grow!(4096, 131072, call2)

expected effect:

fn enhanced_call2() {
    stacker::maybe_grow(4096,131072, call1);
    stacker::maybe_grow(4096,131072, call1);
    stacker::maybe_grow(4096,131072, call1);
    stacker::maybe_grow(4096,131072, call1);
    ......
    // many times of stacker::maybe_grow(4096,131072, call1);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants