-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 effects of atomic pointer operations #57806
base: master
Are you sure you want to change the base?
Conversation
I think you may still have more effect issues here though, since only some codepaths look at this function result, while others might decided to check the effect bits? Perhaps we should take the current state of https://github.com/JuliaLang/julia/compare/jn/builtin-effects-free instead? julia> Base.infer_effects(Core.Intrinsics.atomic_pointerset, (Ptr{Int}, Int, Symbol))
(+c,+e,!n,+t,+s,+m,+u,+o,+r) I had also previously noted the following additional mistakes in the effect system, while making that branch:
|
Yeah, sure thing. |
372e61d
to
896d0b1
Compare
This commit fixes a bug where `builtin_tfunction` was giving the wrong effects to builtins that weren't actually implemented. xref: #57806 (comment) Now, when we add new builtins, unless we manually update `_EFFECTS_KNOWN_BUILTINS`, they'll automatically get the most conservative `Effects()`. Effects for builtins like `getglobal` are calculated individually inside `abstract_call_builtin`, so there is no handling for them within `builtin_effects` and thus they aren't in `_EFFECTS_KNOWN_BUILTINS`. If we want to give these built-ins a better `stmt_effect_flag`, we need to handle it in `builtin_effects` properly.
The atomic operators, in particular, where missing from the list, though many others were also in incorrect lists also. Try to deduplicate the lists slightly. Co-authored-by: Shuhei Kadowaki <[email protected]>
896d0b1
to
bd67367
Compare
This commit fixes a bug where `builtin_tfunction` was giving the wrong effects to builtins that weren't actually implemented. xref: #57806 (comment) Now, when we add new builtins, unless we manually update `_EFFECTS_KNOWN_BUILTINS`, they'll automatically get the most conservative `Effects()`. Effects for builtins like `getglobal` are calculated individually inside `abstract_call_builtin`, so there is no handling for them within `builtin_effects` and thus they aren't in `_EFFECTS_KNOWN_BUILTINS`. If we want to give these built-ins a better `stmt_effect_flag`, we need to handle it in `builtin_effects` properly.
The
_unsetindex!(::GenericMemoryRef)
function was being concretely evaluated (meaning the code was actually being run during inference) by theREPLInterpreter
.The root cause is that the Base compiler system forgot to mark
atomic_pointerset
as "effect-free".This is simply a bug in the effect system. It didn't cause problems during normal Base compilation because
atomic_pointerset
was correctly marked as "consistent" (concrete evaluation requires both "consistent" and "effect-free"). However, this was still a pretty risky situation.The reason this only caused problems with REPL completion is that the
REPLInterpreter
intentionally ignores the "consistent" requirement under certain conditions to achieve better completion accuracy. This is usually fine, but it relies on "effect-free" being correctly marked. So, when there's a critical bug like this in the effect system, these kinds of dangerous issues can occur.As discussed with Jameson earlier, the effects of atomic pointer operations are not precisely defined.
This commit includes the minimal changes necessary to fix #57780, but a more extensive audit is planned for later.