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

the recursive limit doesn't work with println! and other macros #41731

Closed
gdepoire opened this issue May 3, 2017 · 1 comment · Fixed by #105419
Closed

the recursive limit doesn't work with println! and other macros #41731

gdepoire opened this issue May 3, 2017 · 1 comment · Fixed by #105419
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gdepoire
Copy link

gdepoire commented May 3, 2017

This code makes the compiler crash with a stack overflow (tested on the playground):

fn main() {
    macro_rules! stack {
        ($overflow:expr) => {
            println!(stack!($overflow));
        };
    }
    
    stack!("overflow");
}

You can try this code on the playground.

If you replace the println! by a print!, the compiler will crash with a segmentation fault instead.
You can try this on the playground too.

The compiler doesn't detect the recursive macro. In fact, it only detect them if we remove the println!.

@gdepoire gdepoire changed the title the recursive limit doesn't work everytime the recursive limit doesn't work with println! and other macros May 3, 2017
@Mark-Simulacrum Mark-Simulacrum added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. labels Jun 22, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@jonas-schievink jonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 22, 2019
@sudipghimire533
Copy link

Although this seems to be 4 years before, but I think this issue have been resolved (at least for the example you have provided) isn't it?

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 18, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 19, 2022
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#105419 (Add tests for rust-lang#41731)
 - rust-lang#105447 (Add a test for rust-lang#103095)
 - rust-lang#105842 (print argument name in arg mismatch if possible)
 - rust-lang#105863 (Update browser-ui-test version to reduce GUI tests flakyness)
 - rust-lang#105867 (remove redundant fn params that were only "used" in recursion)
 - rust-lang#105869 (don't clone Copy types)
 - rust-lang#105873 (use &str / String literals instead of format!())
 - rust-lang#105879 (Revert "Introduce lowering_arena to avoid creating AST nodes on the fly")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in cf312ae Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants