rust/src
bors 97f3eeec82 Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obk
Prevent compiler stack overflow for deeply recursive code

I was unable to write a test that

1. runs in under 1s
2. overflows on my machine without this patch

The following reproduces the issue, but I don't think it's sensible to include a test that takes 30s to compile. We can now easily squash newly appearing overflows by the strategic insertion of calls to `ensure_sufficient_stack`.

```rust
// compile-pass

#![recursion_limit="1000000"]

macro_rules! chain {
    (EE $e:expr) => {$e.sin()};
    (RECURSE $i:ident $e:expr) => {chain!($i chain!($i chain!($i chain!($i $e))))};
    (Z $e:expr) => {chain!(RECURSE EE $e)};
    (Y $e:expr) => {chain!(RECURSE Z $e)};
    (X $e:expr) => {chain!(RECURSE Y $e)};
    (A $e:expr) => {chain!(RECURSE X $e)};
    (B $e:expr) => {chain!(RECURSE A $e)};
    (C $e:expr) => {chain!(RECURSE B $e)};
    // causes overflow on x86_64 linux
    // less than 1 second until overflow on test machine
    // after overflow has been fixed, takes 30s to compile :/
    (D $e:expr) => {chain!(RECURSE C $e)};
    (E $e:expr) => {chain!(RECURSE D $e)};
    (F $e:expr) => {chain!(RECURSE E $e)};
    // more than 10 seconds
    (G $e:expr) => {chain!(RECURSE F $e)};
    (H $e:expr) => {chain!(RECURSE G $e)};
    (I $e:expr) => {chain!(RECURSE H $e)};
    (J $e:expr) => {chain!(RECURSE I $e)};
    (K $e:expr) => {chain!(RECURSE J $e)};
    (L $e:expr) => {chain!(RECURSE L $e)};
}

fn main() {
    let x = chain!(D 42.0_f32);
}
```

fixes #55471
fixes #41884
fixes #40161
fixes #34844
fixes #32594

cc @alexcrichton @rust-lang/compiler

I looked at all code that checks the recursion limit and inserted stack growth calls where appropriate.
2020-05-07 00:03:23 +00:00
..
bootstrap Rollup merge of #71731 - mark-i-m:guide-toolstate-off-for-now, r=kennytm 2020-05-06 22:36:45 +02:00
build_helper
ci Turn of rustc-dev-guide toolstate for now 2020-04-30 21:50:43 -05:00
doc Rollup merge of #71897 - alexcrichton:embed-bitcode-docs, r=nnethercote 2020-05-05 12:55:13 +02:00
etc
liballoc Rollup merge of #71510 - ssomers:btreemap_iter_intertwined, r=Mark-Simulacrum 2020-05-06 13:22:05 +02:00
libarena
libcore Rollup merge of #71944 - ldm0:arrordhint, r=sfackler 2020-05-06 16:59:04 +02:00
libfmt_macros Dogfood more or_patterns in the compiler 2020-04-19 07:33:58 -07:00
libgraphviz
libpanic_abort Bump bootstrap compiler 2020-04-25 09:25:33 -04:00
libpanic_unwind Bump bootstrap compiler 2020-04-25 09:25:33 -04:00
libproc_macro Rollup merge of #68716 - petrochenkov:stabmixed, r=dtolnay 2020-04-27 03:26:05 +02:00
libprofiler_builtins
librustc_apfloat Dogfood more or_patterns in the compiler 2020-04-19 07:33:58 -07:00
librustc_ast Rollup merge of #71762 - tshepang:typo, r=jonas-schievink 2020-05-01 23:16:40 +02:00
librustc_ast_lowering Move ensure_sufficient_stack to data_structures 2020-05-02 16:47:52 +02:00
librustc_ast_passes Add docstring to deny_equality_constraints 2020-05-04 11:09:10 -07:00
librustc_ast_pretty Remove unused dependencies 2020-04-20 17:59:27 +09:00
librustc_attr Add build script to rustc_attr because of cfg(version) 2020-05-03 02:42:12 +02:00
librustc_builtin_macros fix typo in function name 2020-05-04 18:27:23 -04:00
librustc_codegen_llvm Rollup merge of #69984 - lenary:lenary/force-uwtables, r=hanna-kruppe 2020-05-05 12:55:08 +02:00
librustc_codegen_ssa Rollup merge of #71269 - Mark-Simulacrum:sat-float-casts, r=nikic 2020-05-06 16:58:50 +02:00
librustc_data_structures Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obk 2020-05-07 00:03:23 +00:00
librustc_driver fix more clippy warnings 2020-04-26 02:24:01 +02:00
librustc_error_codes Add stability attribute to E0539 error examples 2020-05-03 00:25:45 +03:00
librustc_errors Rollup merge of #71489 - spastorino:fix-treat-err-as-bug-handling, r=eddyb 2020-04-28 13:12:14 +02:00
librustc_expand Implement confusable_idents lint. 2020-05-03 02:30:50 +08:00
librustc_feature Implement RFC 2523, #[cfg(version(..))] 2020-05-03 02:42:07 +02:00
librustc_fs_util
librustc_hir review comments: use or-pattern 2020-05-04 09:53:15 -07:00
librustc_hir_pretty Remove unused dependencies 2020-04-20 17:59:27 +09:00
librustc_incremental Don't copy bytecode files into the incr. comp. cache. 2020-05-01 08:14:39 -07:00
librustc_index
librustc_infer Restore the snapshot/rollback optimization for region constraints 2020-05-05 11:25:12 +02:00
librustc_interface Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obk 2020-05-07 00:03:23 +00:00
librustc_lexer Revert "Rollup merge of #71372 - ayushmishra2005:shebang_stripping, r=estebank" 2020-04-28 13:02:58 +03:00
librustc_lint Rollup merge of #71773 - tshepang:links, r=davidtwco 2020-05-04 16:15:32 +02:00
librustc_llvm Don't skip building LLVM if already built 2020-05-02 18:43:55 -04:00
librustc_macros Monomorphise load_from_disk_and_cache_in_memory. 2020-05-01 14:29:35 +02:00
librustc_metadata Rollup merge of #71813 - ecstatic-morse:issue-71734, r=tmandry 2020-05-03 14:18:08 +05:30
librustc_middle Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obk 2020-05-07 00:03:23 +00:00
librustc_mir Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obk 2020-05-07 00:03:23 +00:00
librustc_mir_build Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obk 2020-05-07 00:03:23 +00:00
librustc_parse Implement confusable_idents lint. 2020-05-03 02:30:50 +08:00
librustc_passes Rollup merge of #71777 - petrochenkov:crtype, r=Mark-Simulacrum 2020-05-02 18:27:39 +02:00
librustc_plugin_impl Remove support for self-opening 2020-04-25 10:55:20 -04:00
librustc_privacy Accept LocalDefId as key for check_mod_privacy query 2020-04-27 23:55:41 +01:00
librustc_query_system Auto merge of #71754 - alexcrichton:no-bitcode-in-cache, r=nnethercote 2020-05-04 14:14:55 +00:00
librustc_resolve resolve: Relax fresh binding disambiguation slightly to fix regression 2020-05-03 17:39:03 +03:00
librustc_save_analysis Accept LocalDefId as keyt for names_imported_by_glob_use 2020-04-27 21:50:17 +01:00
librustc_session Rollup merge of #71269 - Mark-Simulacrum:sat-float-casts, r=nikic 2020-05-06 16:58:50 +02:00
librustc_span Support liveness in rustc_peek tests 2020-05-03 11:36:11 -07:00
librustc_symbol_mangling Modify as_local_hir_id to return a bare HirId 2020-04-23 23:14:07 +01:00
librustc_target Auto merge of #71623 - petrochenkov:localink, r=estebank 2020-05-01 04:43:28 +00:00
librustc_trait_selection Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obk 2020-05-07 00:03:23 +00:00
librustc_traits Move ensure_sufficient_stack to data_structures 2020-05-02 16:47:52 +02:00
librustc_ty fix rustdoc warnings 2020-05-02 10:41:04 +02:00
librustc_typeck Rollup merge of #71888 - lcnr:refactor-suggest_traits_to_import, r=estebank 2020-05-06 22:36:49 +02:00
librustdoc Rollup merge of #71918 - GuillaumeGomez:rename-methods-section, r=Dylan-DPC 2020-05-06 22:36:51 +02:00
libserialize Update src/libserialize/json.rs 2020-05-02 08:51:54 +02:00
libstd Rollup merge of #71591 - hermitcore:thread_create, r=hanna-kruppe 2020-05-06 16:58:53 +02:00
libterm Replace filter_map().next() calls with find_map() 2020-04-24 20:03:45 -07:00
libtest
libunwind Use -fvisibility=hidden for libunwind 2020-05-05 12:41:23 -07:00
llvm-project@3ba91917e5 Store LLVM bitcode in object files, not compressed 2020-04-29 11:57:26 -07:00
rtstartup
rustc
rustllvm Auto merge of #71528 - alexcrichton:no-more-bitcode, r=nnethercote 2020-04-29 23:47:27 +00:00
stdarch@d10eefc622 Update stdarch submodule 2020-04-24 22:15:12 +01:00
test Rollup merge of #71950 - RalfJung:try-validation-cleanup, r=oli-obk 2020-05-06 22:36:55 +02:00
tools Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obk 2020-05-07 00:03:23 +00:00
README.md
stage0.txt Bump rustfmt to most recently shipped 2020-04-25 09:25:33 -04:00

This directory contains the source code of the rust project, including:

  • rustc and its tests
  • libstd
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.