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

fix stack overflow by enum and const #36458

Closed
wants to merge 1 commit into from

Conversation

mikhail-m1
Copy link
Contributor

fixes #36163

@rust-highfive
Copy link
Collaborator

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@mikhail-m1
Copy link
Contributor Author

I'll fix it

@mikhail-m1 mikhail-m1 force-pushed the stack-overflow branch 2 times, most recently from ab3bb8a to dc4a0cb Compare September 16, 2016 16:22
@mikhail-m1 mikhail-m1 changed the title fix stack overflow by enum and cont fix stack overflow by enum and const Sep 16, 2016
@bors
Copy link
Contributor

bors commented Sep 22, 2016

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

@mikhail-m1
Copy link
Contributor Author

mikhail-m1 commented Sep 22, 2016

@arielb1 Could you look at my PR or may be suggest other reviewer? I'll fix conflicts ASAP

Copy link
Contributor

@arielb1 arielb1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your PR looks great, however:

  • There are a few issues with the coding style. You should fix them.
  • Your PR comment should mention the issue fixed - that some paths were skipped while checking for recursion.

}

impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
fn visit_item(&mut self, it: &'ast hir::Item) {
fn visit_item<'b>(&'b mut self, it: &'ast hir::Item) {
Copy link
Contributor

@arielb1 arielb1 Sep 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the 'b? Lifetime elision should insert it by itself.

sess: &'a Session,
ast_map: &'a ast_map::Map<'ast>,
def_map: &'a DefMap,
struct CheckItemRecursionVisitor<'a, 'b: 'a, 'ast: 'b> {
Copy link
Contributor

@arielb1 arielb1 Sep 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 2 lifetimes here? What was the problem with only 'a?

@@ -34,10 +34,11 @@ struct CheckCrateVisitor<'a, 'ast: 'a> {
// each one. If the variant uses the default values (starting from `0`),
// then `None` is stored.
discriminant_map: RefCell<NodeMap<Option<&'ast hir::Expr>>>,
detected_ids: Vec<ast::NodeId>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a NodeSet and not a Vec, to avoid O(n^2).

Copy link
Contributor

@arielb1 arielb1 Sep 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm this is only non-empty when errors occur. Might want to add a comment to that effect?


fn process_node(&mut self, id: ast::NodeId, span: Span) {
match self.def_map.get(&id).map(|d| d.base_def) {
Some(Def::Static(def_id, _)) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: function should be named process_def or something.

// might be (if any).
Some(Def::Variant(enum_id, variant_id)) => {
if let Some(enum_node_id) = self.ast_map.as_local_node_id(enum_id) {
if let hir::ItemEnum(ref enum_def, ref generics) = self.ast_map
Copy link
Contributor

@arielb1 arielb1 Sep 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation. rustc style is to break after the equals sign. are you using rustfmt? Then don't. rustfmt sucks.

@mikhail-m1
Copy link
Contributor Author

@arielb1 Than you for review and sorry for long delay and rustfmt, I forgot run it after last fix.
I've fixed all nits, except two lifetime ('a and 'b). One need for session, maps, .. and another for detected_recursive_ids field from CheckCrateVisitor. Current version of CheckItemRecursionVisitor get descriminant_map as RefCell but I think two life time is better thand RefCell. May be I miss something. I am going to remove RefCell from descriminant_map too, but should it be separate PR?

@bors
Copy link
Contributor

bors commented Oct 5, 2016

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

… were skipped while checking for recursion.
@arielb1
Copy link
Contributor

arielb1 commented Oct 5, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Oct 5, 2016

📌 Commit 60891c9 has been approved by arielb1

@bors
Copy link
Contributor

bors commented Oct 5, 2016

⌛ Testing commit 60891c9 with merge 6784ba3...

bors added a commit that referenced this pull request Oct 5, 2016
fix stack overflow by enum and const

fixes #36163
@bors
Copy link
Contributor

bors commented Oct 5, 2016

💔 Test failed - auto-win-msvc-64-cargotest

@arielb1
Copy link
Contributor

arielb1 commented Oct 5, 2016

  • Timeout

@bors retry

@alexcrichton
Copy link
Member

@bors: retry force clean

  • looks like a new builder was forgotten by accident now

@bors
Copy link
Contributor

bors commented Oct 5, 2016

⌛ Testing commit 60891c9 with merge 4a492ff...

@bors
Copy link
Contributor

bors commented Oct 6, 2016

💔 Test failed - auto-win-msvc-64-cargotest

@alexcrichton
Copy link
Member

@bors: retry

On Wednesday, October 5, 2016, bors notifications@github.com wrote:

💔 Test failed - auto-win-msvc-64-cargotest
https://buildbot.rust-lang.org/builders/auto-win-msvc-64-cargotest/builds/2004


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#36458 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAD95Ab5dWc9RkSQgy0cR8m_dgYFYSUWks5qxEqMgaJpZM4J8F00
.

@bors
Copy link
Contributor

bors commented Oct 6, 2016

⌛ Testing commit 60891c9 with merge 5102bde...

@bors
Copy link
Contributor

bors commented Oct 6, 2016

💔 Test failed - auto-win-msvc-64-cargotest

@alexcrichton
Copy link
Member

@bors: retry

On Wed, Oct 5, 2016 at 10:43 PM, bors notifications@github.com wrote:

💔 Test failed - auto-win-msvc-64-cargotest
https://buildbot.rust-lang.org/builders/auto-win-msvc-64-cargotest/builds/2006


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#36458 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAD95PPe22eVUXsKECTT4lEwIINQ8cuhks5qxIpzgaJpZM4J8F00
.

@alexcrichton
Copy link
Member

@bors: r-

er wait, this seems legitimate!

@mikhail-m1
Copy link
Contributor Author

@alexcrichton How can I reproduce it locally?

@alexcrichton
Copy link
Member

@mikhail-m1

I believe this should work:

./configure --enable-rustbuild
make check-cargotest

@mikhail-m1
Copy link
Contributor Author

@alexcrichton I rebuild it locally after pull and rebase and all tests passed successfully but on x86_64-unknown-linux-gnu

@mikhail-m1
Copy link
Contributor Author

What should be my next step?

@alexcrichton
Copy link
Member

How long did the build take? It looks like something is becoming perhaps pathologically slow although it may still complete (e.g. the build failed as it lacked output for awhile)

@mikhail-m1
Copy link
Contributor Author

mikhail-m1 commented Oct 11, 2016

@alexcrichton step with url crate (I think it's cargotest) took several seconds, may be some way to get some information from CI build? I can rebuild it again collect and share output.

@mikhail-m1
Copy link
Contributor Author

testing https://github.com/iron/iron
...
Finished debug [unoptimized + debuginfo] target(s) in 258.97 secs
testing https://github.com/rust-lang/cargo
...
Finished debug [unoptimized + debuginfo] target(s) in 743.97 secs
but some tests failed, but my PR cannot affect it

full log: https://www.dropbox.com/s/wbi7esu7a9mapxx/build2.log?dl=0

@alexcrichton
Copy link
Member

Closing due to inactivity but feel free to resubmit with tests fixed!

bors added a commit that referenced this pull request Dec 5, 2016
fix stack overflow by enum and cont issue #36163

some paths were skipped while checking for recursion.

I fixed bug reproduces on win64 cargo test. In previous PR #36458 time complexity was exponential in case of linked const values. Now it's linear.

r? @alexcrichton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stack overflow by enum and const
5 participants