Bump rust, fix stack overflows#1
Closed
jgreenbaum wants to merge 3 commits intostefanlippuner:bump-circtfrom
Closed
Bump rust, fix stack overflows#1jgreenbaum wants to merge 3 commits intostefanlippuner:bump-circtfrom
jgreenbaum wants to merge 3 commits intostefanlippuner:bump-circtfrom
Conversation
added 3 commits
June 24, 2025 18:49
But tests fail as mentioned in the comments to the existing pull request: "Building moore with v1.67 or newer results in stack overflows at runtime (e.g. when running the tests). I think fixing this can be deferred for now.": fabianschuiki#252
All the tests in `test/run.sh` pass now. Using procout I was able to debug the output of derive::query::derive_query_db. What I saw was that key comparison functions were "aliasing" in the caches, so it kept retrieving the same scope over and over until the stack overflowed. Looking at the code I saw PartialEq and Hash being derived for keys with the arg signature of `&dyn *Node`, so any of the different Node traits. While debugging I could see that the references were identical for different `Node::id` values. This makes some sense, Rust doesn't guarantee that a reference to an object remains unchanged unless you `Pin` it. It looks like it kept reusing the same memory in different iterations of a loop. The solution I implemented replaces the derived `PartialEq` and `Hash` for keys with a single arg that is a `&dyn *Node`, and instead generates implementations that use the `Node::id()` instead of the reference. I'm not sure this is what is expected. I see comments in the code about moving away from node ids. But unless you put `Box::pin` objects into the cache you need to use a memory independent id like `Node::id()`.
Owner
|
Hi @jgreenbaum Thanks for taking the time to update the toolchain and fixing the issues! For me, it's ok to merge your changes here. However, as Fabian has merged fabianschuiki#252, would it perhaps make sense to open a PR there s.t. the central repo has the most recent version? (it's not really like this is a maintained fork....). Let me know what you would prefer. (The rustfmt CI job also appears to fail due to some whitespace issues, but that can be resolved easily) |
Author
That makes sense to me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since Stefan's pull request in the main repo wasn't merged, I've based my work on this branch. Perhaps this isn't much of interest, I see from commits that perhaps moore/llhd development has moved into the CIRCT repo in C++. But I was curious about Moore so here it is.
There are three commits. The first (f4abc83) just makes it build with no warnings with the latest stable rust, which is 1.87.0 at the time of this PR. The second (3cfd5ad) fixes the stack overflows -- the default derived
PartialEqandHashfor&dyn *Nodereferences don't work without pinned memory. The final commit (a774e03) just marks up the build commands for LLVM and CIRCT in theReadme.mdto use Ninja.I hope this is useful.