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 recursion detection in constant prop #36148

Merged
merged 1 commit into from
Jun 6, 2020
Merged

Conversation

JeffBezanson
Copy link
Member

#36058 was a bit too optimistic, and caused the inference stack overflow found here: JuliaGraphics/Gtk.jl#512 (comment)

This extra check fixes it while allowing the case in #36058 to still work.

@JeffBezanson JeffBezanson added bugfix This change fixes an existing bug compiler:inference Type inference labels Jun 4, 2020
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Ah, right, I'd completely forgotten that the reason I had been avoiding this was due to the lack of a type-complexity limit. I'm somewhat confused though why this doesn't break the other test though.

Comment on lines 263 to 278
# if there might be a cycle, check to make sure we don't end up
# calling ourselves here.
infstate = sv
while !(infstate === nothing)
if method === infstate.linfo.def
return Any
end
infstate = infstate.parent
end
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# if there might be a cycle, check to make sure we don't end up
# calling ourselves here.
infstate = sv
while !(infstate === nothing)
if method === infstate.linfo.def
return Any
end
infstate = infstate.parent
end
# if edgecycle is true, then there is a cycle and we're calling ourself
return Any

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, that would just revert the original PR. What we need is to find out if adding the constant information breaks the cycle. Maybe we could do a full recursion check, but only look for other frames coming from constant prop?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, right we could probably make edgecycle computation more lenient to allow one identical parent to have the constant-prop flag set and still be good here.

Copy link
Member Author

Choose a reason for hiding this comment

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

What is the best way to check that flag? any(result.overridden_by_const)?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds about right

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Ah, right, I'd completely forgotten that the reason I had been avoiding this was due to the lack of a recursion type-complexity limit. I'm somewhat confused though why this doesn't break the other test though, but I think it's because it's only looking through a subset of the parents (some of the parents are in the callers_in_cycle array, and checking both I think is equivalent to returning unconditionally here)

@JeffBezanson
Copy link
Member Author

some of the parents are in the callers_in_cycle array, and checking both I think is equivalent to returning unconditionally here

I tried it, and that is correct as far as I can tell.

@JeffBezanson JeffBezanson merged commit 87a416f into master Jun 6, 2020
@JeffBezanson JeffBezanson deleted the jb/constproprec branch June 6, 2020 07:04
simeonschaub pushed a commit to simeonschaub/julia that referenced this pull request Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug compiler:inference Type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants