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

Hangs on derive macro invoked by format string macro #44692

Closed
dtolnay opened this issue Sep 19, 2017 · 4 comments · Fixed by #62476
Closed

Hangs on derive macro invoked by format string macro #44692

dtolnay opened this issue Sep 19, 2017 · 4 comments · Fixed by #62476
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Sep 19, 2017

The compiler hangs when compiling the following code.

macro_rules! hang {
    () => {
        {
            #[derive(Clone)]
            struct S;

            ""
        }
    }
}

fn main() {
    format_args!(hang!());
}

This is a regression in 1.20.0. The same code terminates with an error "format argument must be a string literal" in 1.19.0, which is the correct behavior.

@aidanhs aidanhs added the C-bug Category: This is a bug. label Sep 19, 2017
@dtolnay dtolnay added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) I-compiletime Issue: Problems and improvements with respect to compile times. labels Feb 19, 2019
@dtolnay
Copy link
Member Author

dtolnay commented Feb 19, 2019

According to @steffengy in #47188 (comment) -- this is hitting an infinite loop in libsyntax_pos/lib.rs#macro_backtrace. See that comment for details.

@dtolnay dtolnay added I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. and removed I-compiletime Issue: Problems and improvements with respect to compile times. labels Jul 3, 2019
@dtolnay
Copy link
Member Author

dtolnay commented Jul 3, 2019

Transferring nomination by @jonas-schievink in #62167.

@pnkfelix
Copy link
Member

pnkfelix commented Jul 4, 2019

triage: P-high. Removing nomination. Assigning to @petrochenkov for primary investigation, and to myself to follow up on it.

@pnkfelix pnkfelix added P-high High priority and removed I-nominated labels Jul 4, 2019
@petrochenkov
Copy link
Contributor

Accidentally fixed in #62476.

petrochenkov added a commit to petrochenkov/rust that referenced this issue Jul 10, 2019
Add a test for the issue resolved by removing `resolve_macro_path`

Add a test making sure that extern prelude entries introduced from an opaque macro are not visible anywhere, even it that macro

Fix test output after rebase
Centril added a commit to Centril/rust that referenced this issue Jul 11, 2019
Continue refactoring macro expansion and resolution

This PR continues the work started in rust-lang#62042.
It contains a set of more or less related refactorings with the general goal of making things simpler and more orthogonal.
Along the way most of the issues uncovered in rust-lang#62086 are fixed.

The PR is better read in per-commit fashion with whitespace changes ignored.
I tried to leave some more detailed commit messages describing the motivation behind the individual changes.

Fixes rust-lang#44692
Fixes rust-lang#52363
Unblocks rust-lang#62086
r? @matthewjasper
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-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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