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

Splatting into push! for arrays of eltype Any is broken for length bigger than four after having loaded LoopVectorization #48085

Closed
mwlidar opened this issue Jan 2, 2023 · 8 comments · Fixed by #48152
Labels
bug Indicates an unexpected problem or unintended behavior regression Regression in behavior compared to a previous version
Milestone

Comments

@mwlidar
Copy link

mwlidar commented Jan 2, 2023

[Issue updated by @KristofferC to include info about LoopVectorization]

On v1.9.0-beta2 splatting into push! does not work for Arrays of eltype Any for more than four arguments

julia> using LoopVectorization

julia> aa = []
Any[]

julia> push!(aa, [1,2,3,4,5,6]...)
4-element Vector{Any}:
 1
 2
 3
 4

It works on 1.8.3 and for example for Arrays of type Int. Have not tried others so far...

This is on windows:

Julia Version 1.9.0-beta2
Commit 7daffeecb8 (2022-12-29 07:45 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 4 on 8 virtual cores
Environment:
  JULIA_NUM_THREADS = 4
  JULIA_PKG_DEVDIR = H:\pc\julia
  JULIA_EDITOR = code
@giordano
Copy link
Contributor

giordano commented Jan 2, 2023

Works on master:

julia> aa = []
Any[]

julia> push!(aa, [1,2,3,4,5,6]...)
6-element Vector{Any}:
 1
 2
 3
 4
 5
 6

julia> aa
6-element Vector{Any}:
 1
 2
 3
 4
 5
 6

@KristofferC
Copy link
Member

KristofferC commented Jan 2, 2023

Works on 1.9.2 for me (Mac):

julia> aa = []
Any[]

julia> push!(aa, [1,2,3,4,5,6]...)
6-element Vector{Any}:
 1
 2
 3
 4
 5
 6

@mwlidar
Copy link
Author

mwlidar commented Jan 2, 2023

Ok, found the culprit...
On a pristine session the error does not occur. But I had loaded a few modules which I use as a standard and among them LoopVectorization. Without LoopVectorization everything is fine.

@giordano giordano closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2023
@KristofferC
Copy link
Member

KristofferC commented Jan 2, 2023

Before closing, we should probably figure out what is happening here.

Does not happen when running through debugger:

julia> using LoopVectorization

julia> aa=[]; push!(aa, 1,2,3,4,5,6)
4-element Vector{Any}:
 1
 2
 3
 4

julia> using Debugger

julia> aa=[]; @run push!(aa, 1,2,3,4,5,6)
6-element Vector{Any}:
 1
 2
 3
 4
 5
 6

Does not happen when running with --compiled-modules=no.

@KristofferC KristofferC reopened this Jan 2, 2023
@KristofferC
Copy link
Member

KristofferC commented Jan 2, 2023

It seems to break when this method is defined https://github.com/JuliaSIMD/LoopVectorization.jl/blob/35f83103c12992ddd887cd709bf65e345db5ec9e/src/modeling/graphs.jl#L1653-L1667 (which is a Base.push! method)...

Regressed between 1.9.0-alpha1 and 1.9.0-beta2

@KristofferC KristofferC changed the title Splatting into push! for arrays of eltype Any is broken for length bigger than four Splatting into push! for arrays of eltype Any is broken for length bigger than four after having loaded LoopVectorization Jan 2, 2023
@gbaraldi
Copy link
Member

gbaraldi commented Jan 2, 2023

Bisected to 31df7c8
@vtjnash

@KristofferC
Copy link
Member

KristofferC commented Jan 3, 2023

MWE is:

A.jl:

module A
using B
function Base.push!(a,b,c,d) end
end

B.jl:

module B
f() = push!(a, nothing, nothing, nothing, nothing)
precompile(Tuple{typeof(f)})
end

REPL:

julia> push!(LOAD_PATH, ".");

julia> using A

julia> aa = []
Any[]

julia> push!(aa, [1,2,3,4,5,6]...)
4-element Vector{Any}:
 1
 2
 3
 4

@KristofferC KristofferC added this to the 1.9 milestone Jan 3, 2023
@vtjnash
Copy link
Member

vtjnash commented Jan 4, 2023

Isolated to this

(rr) p jl_(jl_normalize_to_compilable_mi(mi))
push!(Array{Any, 1}, Any, Any, Any, Any) from push!(Array{Any, 1}, Any...)
$43 = void
(rr) p jl_(mi)
push!(Array{Any, 1}, Any, Any, Any, Any...) from push!(Array{Any, 1}, Any...)
$44 = void

This is not correct though, since jl_normalize_to_compilable_mi should be wider than the input type, but here it forgot to rewrap in the Vararg bound

@vtjnash vtjnash added bug Indicates an unexpected problem or unintended behavior regression Regression in behavior compared to a previous version labels Jan 4, 2023
vtjnash added a commit that referenced this issue Jan 6, 2023
Some code cleanup, and an early exit path that avoids trying to create a
compilation signature from something that cannot be turned into one.
Previously we might try a little too hard to make one, even if it meant
we ignored that it was expected to be Varargs.

Fix #48085
vtjnash added a commit that referenced this issue Jan 9, 2023
Some code cleanup, and an early exit path that avoids trying to create a
compilation signature from something that cannot be turned into one.
Previously we might try a little too hard to make one, even if it meant
we ignored that it was expected to be Varargs.

Fix #48085
KristofferC pushed a commit that referenced this issue Jan 10, 2023
Some code cleanup, and an early exit path that avoids trying to create a
compilation signature from something that cannot be turned into one.
Previously we might try a little too hard to make one, even if it meant
we ignored that it was expected to be Varargs.

Fix #48085

(cherry picked from commit 45c81b1)
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 regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants