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

Don't unwind when hitting the macro expansion recursion limit #69497

Merged
merged 2 commits into from
Mar 21, 2020

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Feb 26, 2020

This removes one use of FatalError.raise().

r? @petrochenkov

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 26, 2020
@rust-highfive

This comment has been minimized.

@Zoxc Zoxc force-pushed the ast-fragment-error branch from 4747a99 to 17312df Compare February 26, 2020 23:19
@Zoxc
Copy link
Contributor Author

Zoxc commented Feb 27, 2020

Hm.. it seems like ui\issues\issue-16098.rs relies on the early exit here to avoid long compile times.

macro_rules! prob1 {
    (0) => {
        0
    };
    ($n:expr) => {
        if ($n % 3 == 0) || ($n % 5 == 0) {
            $n + prob1!($n - 1); //~ ERROR recursion limit reached while expanding `prob1!`
        } else {
            prob1!($n - 1);
        }
    };
}

fn main() {
    println!("Problem 1: {}", prob1!(1000));
}

@petrochenkov
Copy link
Contributor

it seems like ui\issues\issue-16098.rs relies on the early exit here to avoid long compile times.

Interesting, I wanted to remove this fatal error too, and expected producing a dummy fragment to work.

@petrochenkov
Copy link
Contributor

Each call to error_recursion_limit_reached could halve the recursion limit and silence all the following recursion limit messages for the current ExtCtxt.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 27, 2020
@Zoxc
Copy link
Contributor Author

Zoxc commented Feb 29, 2020

@petrochenkov I tried using an early exit from expand_invoc once the recursion limit was hit. That wasn't sufficient to make issue-16098.rs complete in a timely manner.

@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 1, 2020
@petrochenkov
Copy link
Contributor

petrochenkov commented Mar 1, 2020

The problem here is not entirely in expansion.
With #69497 (comment) rustc --pretty=expanded issue-16098.rs completes in less than a second.

The generated AST is enormous though, so later compilation phases take a lot of time (~7.5 minutes).

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 1, 2020
@bors
Copy link
Contributor

bors commented Mar 7, 2020

☔ The latest upstream changes (presumably #69796) made this pull request unmergeable. Please resolve the merge conflicts.

@Zoxc Zoxc force-pushed the ast-fragment-error branch from 17312df to 511b73f Compare March 14, 2020 20:33
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-03-14T20:34:08.1259859Z ========================== Starting Command Output ===========================
2020-03-14T20:34:08.1262746Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/7b4291e2-8b59-4308-ba37-819cbfe8cf11.sh
2020-03-14T20:34:08.1263020Z 
2020-03-14T20:34:08.1268316Z ##[section]Finishing: Disable git automatic line ending conversion
2020-03-14T20:34:08.1287969Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69497/merge to s
2020-03-14T20:34:08.1291750Z Task         : Get sources
2020-03-14T20:34:08.1292037Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-14T20:34:08.1292312Z Version      : 1.0.0
2020-03-14T20:34:08.1292522Z Author       : Microsoft
---
2020-03-14T20:34:09.1104921Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-03-14T20:34:09.1111163Z ##[command]git config gc.auto 0
2020-03-14T20:34:09.1115494Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-03-14T20:34:09.1119916Z ##[command]git config --get-all http.proxy
2020-03-14T20:34:09.1127144Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/69497/merge:refs/remotes/pull/69497/merge
---
2020-03-14T21:33:01.4335094Z .................................................................................................... 1700/9771
2020-03-14T21:33:05.6138365Z .................................................................................................... 1800/9771
2020-03-14T21:33:17.2119161Z ...................................................................i................................ 1900/9771
2020-03-14T21:33:23.8635430Z .................................................................................................... 2000/9771
2020-03-14T21:33:38.2720801Z .........................................................iiiii...................................... 2100/9771
2020-03-14T21:33:48.0343173Z .................................................................................................... 2300/9771
2020-03-14T21:33:50.0441925Z .................................................................................................... 2400/9771
2020-03-14T21:33:52.9653648Z .................................................................................................... 2500/9771
2020-03-14T21:34:13.9597361Z .................................................................................................... 2600/9771
---
2020-03-14T21:36:50.6076895Z .............................i...............i...................................................... 5000/9771
2020-03-14T21:36:59.6465849Z .................................................................................................... 5100/9771
2020-03-14T21:37:05.3701723Z ........................................................................i........................... 5200/9771
2020-03-14T21:37:10.6652654Z .................................................................................................... 5300/9771
2020-03-14T21:37:19.7866531Z .....................................................ii.ii........i...i............................. 5400/9771
2020-03-14T21:37:27.4842039Z .................................................................................................... 5600/9771
2020-03-14T21:37:36.4926993Z .................................................................................................... 5700/9771
2020-03-14T21:37:42.1953048Z .............................................i...................................................... 5800/9771
2020-03-14T21:37:48.1856754Z ............................................F....................................................... 5900/9771
2020-03-14T21:37:48.1856754Z ............................................F....................................................... 5900/9771
2020-03-14T21:37:57.6467185Z .................................................................................................... 6000/9771
2020-03-14T21:38:03.4709848Z .......................................ii...i..ii...........i....................................... 6100/9771
2020-03-14T21:38:22.6941398Z .................................................................................................... 6300/9771
2020-03-14T21:38:29.2810675Z .................................................................................................... 6400/9771
2020-03-14T21:38:29.2810675Z .................................................................................................... 6400/9771
2020-03-14T21:38:37.5962653Z .....................................................................i..ii.......................... 6500/9771
2020-03-14T21:38:59.1708408Z .................................................................................................... 6700/9771
2020-03-14T21:39:07.2915798Z ...................................................................i................................ 6800/9771
2020-03-14T21:39:09.1718758Z .................................................................................................... 6900/9771
2020-03-14T21:39:11.7205697Z .................................................................................................... 7000/9771
---
2020-03-14T21:40:50.4353276Z .................................................................................................... 7800/9771
2020-03-14T21:40:56.0338721Z .................................................................................................... 7900/9771
2020-03-14T21:41:01.5156549Z ...................................................i................................................ 8000/9771
2020-03-14T21:41:11.7128666Z .................................................................................................... 8100/9771
2020-03-14T21:41:17.0658823Z iiiiiiiiii.i........................................................................................ 8200/9771
2020-03-14T21:41:30.9197252Z .................................................................................................... 8400/9771
2020-03-14T21:41:41.2714450Z .................................................................................................... 8500/9771
2020-03-14T21:41:53.3323562Z .................................................................................................... 8600/9771
2020-03-14T21:41:58.6950788Z .................................................................................................... 8700/9771
---
2020-03-14T21:43:44.7322529Z failures:
2020-03-14T21:43:44.7344836Z 
2020-03-14T21:43:44.7345593Z ---- [ui] ui/macros/trace_faulty_macros.rs stdout ----
2020-03-14T21:43:44.7345821Z 
2020-03-14T21:43:44.7346705Z error: /checkout/src/test/ui/macros/trace_faulty_macros.rs:16: unexpected error: '16:9: 16:11: expected expression, found `A { a: a, b: 0, c: _, .. }`'
2020-03-14T21:43:44.7347475Z error: 1 unexpected errors found, 0 expected errors not found
2020-03-14T21:43:44.7347805Z status: exit code: 1
2020-03-14T21:43:44.7347805Z status: exit code: 1
2020-03-14T21:43:44.7350147Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/macros/trace_faulty_macros.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/trace_faulty_macros" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-A" "unused" "-Z" "trace-macros" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/trace_faulty_macros/auxiliary"
2020-03-14T21:43:44.7351975Z     Error {
2020-03-14T21:43:44.7352205Z         line_num: 16,
2020-03-14T21:43:44.7352436Z         kind: Some(
2020-03-14T21:43:44.7352650Z             Error,
2020-03-14T21:43:44.7352650Z             Error,
2020-03-14T21:43:44.7352855Z         ),
2020-03-14T21:43:44.7353221Z         msg: "16:9: 16:11: expected expression, found `A { a: a, b: 0, c: _, .. }`",
2020-03-14T21:43:44.7353740Z ]
2020-03-14T21:43:44.7353857Z 
2020-03-14T21:43:44.7354563Z thread '[ui] ui/macros/trace_faulty_macros.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:1436:13
2020-03-14T21:43:44.7355115Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---
2020-03-14T21:43:44.7357914Z 
2020-03-14T21:43:44.7368103Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:348:22
2020-03-14T21:43:44.7368422Z 
2020-03-14T21:43:44.7368537Z 
2020-03-14T21:43:44.7372807Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-7/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "7.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2020-03-14T21:43:44.7380585Z 
2020-03-14T21:43:44.7380704Z 
2020-03-14T21:43:44.7381038Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2020-03-14T21:43:44.7381428Z Build completed unsuccessfully in 1:04:09
2020-03-14T21:43:44.7381428Z Build completed unsuccessfully in 1:04:09
2020-03-14T21:43:44.7442712Z == clock drift check ==
2020-03-14T21:43:44.7473607Z   local time: Sat Mar 14 21:43:44 UTC 2020
2020-03-14T21:43:45.0412661Z   network time: Sat, 14 Mar 2020 21:43:45 GMT
2020-03-14T21:43:45.0413060Z == end clock drift check ==
2020-03-14T21:43:45.4831811Z 
2020-03-14T21:43:45.4926770Z ##[error]Bash exited with code '1'.
2020-03-14T21:43:45.4944532Z ##[section]Finishing: Run build
2020-03-14T21:43:45.5001369Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69497/merge to s
2020-03-14T21:43:45.5007378Z Task         : Get sources
2020-03-14T21:43:45.5007895Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-14T21:43:45.5008367Z Version      : 1.0.0
2020-03-14T21:43:45.5008686Z Author       : Microsoft
2020-03-14T21:43:45.5008686Z Author       : Microsoft
2020-03-14T21:43:45.5009206Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-03-14T21:43:45.5009809Z ==============================================================================
2020-03-14T21:43:45.8187829Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-03-14T21:43:45.8242484Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/69497/merge to s
2020-03-14T21:43:45.8321299Z Cleaning up task key
2020-03-14T21:43:45.8322428Z Start cleaning up orphan processes.
2020-03-14T21:43:45.8498515Z Terminate orphan process: pid (3427) (python)
2020-03-14T21:43:45.8667186Z ##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@Zoxc Zoxc force-pushed the ast-fragment-error branch from 511b73f to 2698eaf Compare March 14, 2020 21:51
@bors
Copy link
Contributor

bors commented Mar 17, 2020

☔ The latest upstream changes (presumably #70062) made this pull request unmergeable. Please resolve the merge conflicts.

@Zoxc Zoxc force-pushed the ast-fragment-error branch from 2698eaf to bdaf9e4 Compare March 17, 2020 15:12
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 17, 2020

I made the compiler exit early after macro expansion if a recursion limit was hit.

@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 17, 2020
@petrochenkov petrochenkov changed the title [WIP] Don't unwind when hitting the macro expansion recursion limit Don't unwind when hitting the macro expansion recursion limit Mar 17, 2020
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 17, 2020

📌 Commit bdaf9e4 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 17, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 17, 2020
…nkov

Don't unwind when hitting the macro expansion recursion limit

This removes one use of `FatalError.raise()`.

r? @petrochenkov
@Centril
Copy link
Contributor

Centril commented Mar 18, 2020

Failed in #70110 (comment), @bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 18, 2020
@Zoxc Zoxc force-pushed the ast-fragment-error branch from bdaf9e4 to 43bee17 Compare March 18, 2020 17:06
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 18, 2020

📌 Commit 43bee17836d416e440802512b9867042d95651fb has been approved by petrochenkov

@bors
Copy link
Contributor

bors commented Mar 18, 2020

🌲 The tree is currently closed for pull requests below priority 5, this pull request will be tested once the tree is reopened

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 18, 2020
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 18, 2020

Still don't know why it failed in the rollup.

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 18, 2020
@bors
Copy link
Contributor

bors commented Mar 19, 2020

☔ The latest upstream changes (presumably #70118) made this pull request unmergeable. Please resolve the merge conflicts.

@Zoxc Zoxc force-pushed the ast-fragment-error branch from 43bee17 to d641ad0 Compare March 19, 2020 14:01
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 20, 2020

Looks like the PR build also failed in #70110, which doesn't happen here. I'm going to assume some other PR was the cause of the failure.

@bors r=petrochenkov

@bors
Copy link
Contributor

bors commented Mar 20, 2020

📌 Commit d641ad0 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 20, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 21, 2020
Rollup of 6 pull requests

Successful merges:

 - rust-lang#69497 (Don't unwind when hitting the macro expansion recursion limit)
 - rust-lang#69901 (add #[rustc_layout(debug)])
 - rust-lang#69910 (Avoid query type in generics)
 - rust-lang#69955 (Fix abort-on-eprintln during process shutdown)
 - rust-lang#70032 (put type params in front of const params in generics_of)
 - rust-lang#70119 (rustc: use LocalDefId instead of DefId in TypeckTables.)

Failed merges:

r? @ghost
@bors bors merged commit a6596f2 into rust-lang:master Mar 21, 2020
@Zoxc Zoxc deleted the ast-fragment-error branch March 21, 2020 19:16
Centril added a commit to Centril/rust that referenced this pull request Mar 21, 2020
Centril added a commit to Centril/rust that referenced this pull request Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants