-
-
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
@allocated
false positive on v1.12?
#57064
Comments
Is this really a regression? The range is allocated within |
Why did it work before v1.12, though? Are you saying this may have been a bugfix in v1.12, and it basically only works by accident in v1.11? |
Another thing to note is that this is connected to julia> function f(r)
sum(r)
end
f (generic function with 1 method)
julia> using Test
julia> @testset "t" begin
@test 0 == @allocated f(1:5)
end;
Test Summary: | Pass Total Time
t | 1 1 0.5s
julia> @testset "t" begin
@test 15 == f(1:5)
@test 0 == @allocated f(1:5)
end;
t: Test Failed at REPL[4]:3
Expression: 0 == #= REPL[4]:3 =# @allocated(f(1:5))
Evaluated: 0 == 32 As you can see, the only difference between the failing and the passing test set is the seemingly-unrelated additional test. |
Slightly more minimal MWE:
|
Bisected this using the scripts below:
using Test
@testset "Check" begin
str = "hello bello"
@show @allocated hash(str)
@show @allocated hash(str)
end
const GOOD_COMMIT_HASH = "a127ab7ceeb543483aa8cb86e985c32556c60248"
const BAD_COMMIT_HASH = "f91436eae7265a01bff17e35887cd9b8e15c8fdc"
const MWE_PATH = "..."
const JULIA_MASTER_BIN_PATH = "..."
const MANIFEST_PATH = "..."
function init_bisect()
@info "Initializing bisect"
run(`git reset --hard $BAD_COMMIT_HASH`)
run(`git bisect reset`)
run(`git bisect start`)
run(`git checkout $GOOD_COMMIT_HASH`)
run(`git bisect good`)
run(`git checkout $BAD_COMMIT_HASH`)
run(`git bisect bad`)
end
function bisect_has_finished()
@info "Checking if bisect has finished"
# grep for the string `is the first bad commit` in the output of the bisect log
return contains(read(`git bisect log`, String), "is the first bad commit")
end
function run_bisect()
while !bisect_has_finished()
# clean and build the julia master branch
run(`make cleanall`)
run(`make -j8`)
# create temporary output file
run(`touch bisect_output.txt`)
# rm the Manifest.toml
rm("$MANIFEST_PATH", force=true)
# run the MWE and save the output to the temporary files
run(pipeline(`$JULIA_MASTER_BIN_PATH $MWE_PATH`, `tee bisect_output.txt`))
# count the number of occurences of `@allocated(hash(str)) = 0` in the output
n = count(r"@allocated\(hash\(str\)\) = 0", read("bisect_output.txt", String))
@info "Number of occurences of @allocated(hash(str)) = 0: $n"
if n == 2
run(`git bisect good`)
else
run(`git bisect bad`)
end
rm("bisect_output.txt")
end
end
function main()
init_bisect()
run_bisect()
end
main() And got:
|
Is #56509 a reasonable candidate for breaking this? (Not familiar with the PR). |
CC: @Keno. |
Yes, this is an explicit feature of that PR (insert_toplevel_latestworld):
|
In particular: #56509 (comment) Maybe we add additional logic to grep for |
I think the answer depends on what that test is really trying to do. We don't really have semantic guarantees around |
This passes on v1.11, but fails on v1.12:
The workaround is:
The text was updated successfully, but these errors were encountered: