-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustc overflowed its stack when compiling 148,492 lines of code. #78567
Comments
Can you collect a backtrace on the overflowing stack? |
|
By the way, if this pr(#78588) solved the problem, how can I get the patched executable rustc as soon as possible? Will CI upload the compiled rustc to somewhere? |
|
Problem not solved
Rustc with 761d47 commit hash still overflowed, when compiling my project.
Rustc version
|
Thanks for the quick response. Unfortunately, this pr(#78607) didn't fix the problem, rustc still overflowed it stack but with a slower speed. For now, I'll change the code generation logic of my crate to split the long function into multiple shorter functions. However, this kind of limitation should not exist in rustc. Version
Hardware(updated)
|
…davidtwco Transform post order walk to an iterative approach The previous recursive approach might overflow the stack when walking a particularly deep, list-like, graph. In particular, dominator calculation for borrow checking does such a traversal and very long functions might lead to a region dependency graph with in this problematic structure. This addresses what appears to be the cause of rust-lang#78567 (`@SunHao-0` thanks for the stack trace).
Reworks Sccc computation to iteration instead of recursion Linear graphs, producing as many scc's as nodes, would recurse once for every node when entered from the start of the list. This adds a test that exhausted the stack at least on my machine with error: ``` thread 'graph::scc::tests::test_deep_linear' has overflowed its stack fatal runtime error: stack overflow ``` This may or may not be connected to rust-lang#78567. I was only reminded that I started this rework some time ago. It might be plausible as borrow checking a long function with many borrow regions around each other—((((((…))))))— may produce the linear list setup to trigger this stack overflow ? I don't know enough about borrow check to say for sure. This is best read in two separate commits. The first addresses only `find_state` internally. This is classical union phase from union-find. There's also a common solution of using the parent pointers in the (virtual) linked list to track the backreferences while traversing upwards and then following them backwards in a second path compression phase. The second is more involved as it rewrites the mutually recursive `walk_node` and `walk_unvisited_node`. Firstly, the caller is required to handle the unvisited case of `walk_node` so a new `start_walk_from` method is added to handle that by walking the unvisited node if necessary. Then `walk_unvisited_node`, where we would previously recurse into in the missing case, is rewritten to construct a manual stack of its frames. The state fields consist of the previous stack slots.
The file for reproduction is no longer accessible... |
The original reproduction file can be found here (fuzzer/syscalls/linux/amd64.rs). rustc info:
|
I wasn't able to reproduce this. Here's what I tried:
|
Also tried on my local machine, that version of code can be compiled normally with the nightly rustc you mentioned, in debug build. In release build, rustc still cannot compile the code for almost one hour, but this time, no stack overflow happened. I guess we now can close this issue. |
Rustc overflowed its stack when compiling 148,492 lines of code.
Rust is great, but this limitation is unacceptable.
Error
Crate
Loc: 148,492
Large file: fuzzer/syscalls/linux/amd64.rs
Link: https://github.com/SunHao-0/healer/tree/refactor
Hardware
Cpu
Resource limitation
Meta
The text was updated successfully, but these errors were encountered: