Skip to content

Commit

Permalink
Auto merge of #105919 - uweigand:s390x-stack-overflow, r=Nilstrieb
Browse files Browse the repository at this point in the history
Fix stack overflow in recursive AST walk in early lint

The src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs test case added to verify rust-lang/rust#74564 still crashes with a stack overflow on s390x-ibm-linux.

Symptom is a very deep recursion in compiler/rustc_lint/src/early.rs:
    fn visit_expr(&mut self, e: &'a ast::Expr) {
        self.with_lint_attrs(e.id, &e.attrs, |cx| {
            lint_callback!(cx, check_expr, e);
            ast_visit::walk_expr(cx, e);
        })
    }
(where walk_expr recursively calls back into visit_expr).  The crash happens at a nesting depth of over 17000 stack frames when using the default 8 MB stack size on s390x.

This patch fixes the problem by adding a ensure_sufficient_stack call to the with_lint_attrs routine (which also should take care of all the other mutually recursive visitors here).

Fixes part of rust-lang/rust#105383.
  • Loading branch information
bors committed Jan 11, 2023
2 parents 5863e52 + b730a6a commit 32ff9ab
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 32ff9ab

Please sign in to comment.