-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
effects: fix correctness issues of :consistent
-cy analysis
#46111
Conversation
Seems like the uninitialized field access should only be an issue for us it's fields? Otherwise you gen an undef ref error, which is fine from a consistency perspective. |
You mean |
Yes, but we also just usually hope people don't leave undef fields lying around, so that it won't matter and doesn't need to complicate this |
Okay, let's not bother with it for now but just leave a comment why we want to ignore it. |
79236ce
to
1140fc2
Compare
I don't think we can really afford to ignore that complication. undef isbitstype fields are pretty strongly undef (#26764), so this could definitely lead to crashes if we don't taint consistency there. |
That should be the point of this PR (to taint everything)? |
1140fc2
to
c2605f9
Compare
Separated from #46111. This really doesn't matter usually though as the frontend doesn't form `:new` expression anyway.
c2605f9
to
0ea76a8
Compare
0ea76a8
to
0177297
Compare
c185f44
to
0ad5816
Compare
0177297
to
3480e5b
Compare
0ad5816
to
87bd4d3
Compare
3480e5b
to
e7b49d5
Compare
87bd4d3
to
4d84e6c
Compare
e7b49d5
to
5a72248
Compare
5a72248
to
b2bb777
Compare
9494922
to
43a05c0
Compare
base/compiler/tfuncs.jl
Outdated
function getfield_notundefined(@nospecialize(obj), @nospecialize(name)) | ||
if !isa(name, Const) | ||
if !hasintersect(widenconst(name), Union{Int,Symbol}) | ||
# always throw doesn't account for undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to taint :consistent
-cy when a getfield
call is determined to throw. If the thrown object (with a potentially undefined field) is caught later, we will taint it anyway when we see :the_exception
expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct
base/compiler/tfuncs.jl
Outdated
@@ -1817,6 +1855,10 @@ function builtin_effects(f::Builtin, argtypes::Vector{Any}, @nospecialize(rt)) | |||
end | |||
s = s::DataType | |||
consistent = !ismutabletype(s) ? ALWAYS_TRUE : ALWAYS_FALSE | |||
# access to undefined field leads to undefined behavior and should taint `:consistent`-cy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make a note that undefined access of non-isbitstype would be ok, but we model it conservatively for simplicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but there are some test failures that look related.
1e1fe6c
to
e9b560e
Compare
e9b560e
to
54881e2
Compare
effects: fix correctness issues of `:consistent`-cy analysis
Today @vtjnash and I found two correctness issues for
:consistent
-cy::the_exception
should taint:consistent
-cy as much like an allocation:consistent
-cy(in a way that even a return type information can't later refine it)