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

unsafe_load does not taint :noub effect #56056

Open
topolarity opened this issue Oct 8, 2024 · 1 comment
Open

unsafe_load does not taint :noub effect #56056

topolarity opened this issue Oct 8, 2024 · 1 comment
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior compiler:effects effect analysis

Comments

@topolarity
Copy link
Member

do_ub() = unsafe_load(Ptr{Int}(UInt(0)))

This function executes undefined behavior, but the compiler has no idea somehow:

julia> Base.infer_effects(do_ub, ())
(!c,+e,+n,+t,+s,+m,+u,+o,+r)
julia> do_ub()
Warning: detected a stack overflow; program state may be corrupted, so further execution might be unreliable.
ERROR: StackOverflowError:
@topolarity topolarity added compiler:effects effect analysis bug Indicates an unexpected problem or unintended behavior labels Oct 8, 2024
@nsajko
Copy link
Contributor

nsajko commented Jan 22, 2025

Similar, perhaps:

julia> unsafe_getindex(t::Tuple, i::Int) = getfield(t, i, false)
unsafe_getindex (generic function with 1 method)

julia> InteractiveUtils.@infer_effects unsafe_getindex((), 1)
(+c,+e,+n,+t,+s,+m,+u,+o,+r)

julia> unsafe_getindex((), 1)
Unreachable reached at 0x7c963f26350f

[72487] signal 4 (2): Illegal instruction
in expression starting at REPL[3]:1
unsafe_getindex at ./REPL[1]:1
[...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior compiler:effects effect analysis
Projects
None yet
Development

No branches or pull requests

3 participants