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

Revert "Make StridedReinterpretArray's get/setindex pointer based." #52101

Closed
wants to merge 1 commit into from

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Nov 9, 2023

Reverts #44186 because it seems to be segfaulting on CI, even though not clear why they would be related

      From worker 14:
      From worker 14:	Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
      From worker 14:	Exception: EXCEPTION_ACCESS_VIOLATION at 0x87cb8d9 -- memcpy at .\cmem.jl:14 [inlined]
      From worker 14:	_setindex_ra! at .\reinterpretarray.jl:610 [inlined]
      From worker 14:	setindex! at .\reinterpretarray.jl:521 [inlined]
      From worker 14:	macro expansion at C:\workdir\usr\share\julia\stdlib\v1.11\Test\src\Test.jl:676 [inlined]
      From worker 14:	#13 at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\reinterpretarray.jl:79
      From worker 14:	in expression starting at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\reinterpretarray.jl:69
      From worker 14:	memcpy at .\cmem.jl:14 [inlined]
      From worker 14:	_setindex_ra! at .\reinterpretarray.jl:610 [inlined]
      From worker 14:	_setindex_ra! at .\reinterpretarray.jl:610 [inlined]
      From worker 14:	setindex! at .\reinterpretarray.jl:521 [inlined]
      From worker 14:	macro expansion at C:\workdir\usr\share\julia\stdlib\v1.11\Test\src\Test.jl:676 [inlined]
      From worker 14:	#13 at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\reinterpretarray.jl:79
      From worker 14:	#1 at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\reinterpretarray.jl:17
      From worker 14:	unknown function (ip: 087d17ff)
      From worker 14:	_jl_invoke at C:/workdir/src\gf.c:2913 [inlined]
      From worker 14:	ijl_apply_generic at C:/workdir/src\gf.c:3095
      From worker 14:	#62 at .\tuple.jl:617
      From worker 14:	BottomRF at .\reduce.jl:86 [inlined]
      From worker 14:	afoldl at .\operators.jl:553
      From worker 14:	_foldl_impl at .\reduce.jl:68 [inlined]
      From worker 14:	foldl_impl at .\reduce.jl:48 [inlined]
      From worker 14:	mapfoldl_impl at .\reduce.jl:44
      From worker 14:	unknown function (ip: 087c0a82)
      From worker 14:	_jl_invoke at C:/workdir/src\gf.c:2913 [inlined]
      From worker 14:	ijl_apply_generic at C:/workdir/src\gf.c:3095
      From worker 14:	#mapfoldl#316 at .\reduce.jl:175
      From worker 14:	mapfoldl at .\reduce.jl:175 [inlined]
      From worker 14:	#foldl#317 at .\reduce.jl:198 [inlined]
      From worker 14:	foldl at .\reduce.jl:198 [inlined]
      From worker 14:	foreach at .\tuple.jl:617 [inlined]
      From worker 14:	test_many_wrappers at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\reinterpretarray.jl:17 [inlined]
      From worker 14:	test_many_wrappers at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\reinterpretarray.jl:18
      From worker 14:	unknown function (ip: 087c00b8)
      From worker 14:	_jl_invoke at C:/workdir/src\gf.c:2913 [inlined]
      From worker 14:	ijl_apply_generic at C:/workdir/src\gf.c:3095
      From worker 14:	jl_apply at C:/workdir/src\julia.h:2129 [inlined]
      From worker 14:	do_call at C:/workdir/src\interpreter.c:126
      From worker 14:	eval_value at C:/workdir/src\interpreter.c:223
      From worker 14:	eval_stmt_value at C:/workdir/src\interpreter.c:174 [inlined]
      From worker 14:	eval_body at C:/workdir/src\interpreter.c:655
      From worker 14:	jl_interpret_toplevel_thunk at C:/workdir/src\interpreter.c:795
      From worker 14:	jl_toplevel_eval_flex at C:/workdir/src\toplevel.c:938
      From worker 14:	jl_toplevel_eval_flex at C:/workdir/src\toplevel.c:881
      From worker 14:	ijl_toplevel_eval at C:/workdir/src\toplevel.c:947 [inlined]
      From worker 14:	ijl_toplevel_eval_in at C:/workdir/src\toplevel.c:989
      From worker 14:	eval at .\boot.jl:422 [inlined]
      From worker 14:	include_string at .\loading.jl:2133
      From worker 14:	jl_fptr_args at C:/workdir/src\gf.c:2555
      From worker 14:	_jl_invoke at C:/workdir/src\gf.c:2894 [inlined]
      From worker 14:	ijl_apply_generic at C:/workdir/src\gf.c:3095
      From worker 14:	_include at .\loading.jl:2193
      From worker 14:	include at .\Base.jl:525 [inlined]
      From worker 14:	macro expansion at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\testdefs.jl:33 [inlined]
      From worker 14:	macro expansion at C:\workdir\usr\share\julia\stdlib\v1.11\Test\src\Test.jl:1598 [inlined]
      From worker 14:	macro expansion at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\testdefs.jl:26 [inlined]
      From worker 14:	macro expansion at .\timing.jl:506 [inlined]
      From worker 14:	#runtests#1 at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\testdefs.jl:24
      From worker 14:	runtests at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\testdefs.jl:5 [inlined]
      From worker 14:	runtests at C:\buildkite-agent\builds\win2k22-amdci6-3\julialang\julia-master\julia-137783f166\share\julia\test\testdefs.jl:5
      From worker 14:	unknown function (ip: 135113ff)
      From worker 14:	_jl_invoke at C:/workdir/src\gf.c:2894 [inlined]
      From worker 14:	ijl_apply_generic at C:/workdir/src\gf.c:3095
      From worker 14:	jl_apply at C:/workdir/src\julia.h:2129 [inlined]
      From worker 14:	jl_f__call_latest at C:/workdir/src\builtins.c:859
      From worker 14:	jl_fptr_args at C:/workdir/src\gf.c:2555
      From worker 14:	_jl_invoke at C:/workdir/src\gf.c:2894 [inlined]
      From worker 14:	ijl_apply_generic at C:/workdir/src\gf.c:3095
      From worker 14:	jl_apply at C:/workdir/src\julia.h:2129 [inlined]
      From worker 14:	do_apply at C:/workdir/src\builtins.c:815
      From worker 14:	jl_f__apply_iterate at C:/workdir/src\builtins.c:823
      From worker 14:	#invokelatest#2 at .\essentials.jl:930
      From worker 14:	jl_fptr_args at C:/workdir/src\gf.c:2555
      From worker 14:	_jl_invoke at C:/workdir/src\gf.c:2894 [inlined]
      From worker 14:	ijl_apply_generic at C:/workdir/src\gf.c:3095
      From worker 14:	jl_apply at C:/workdir/src\julia.h:2129 [inlined]
      From worker 14:	do_apply at C:/workdir/src\builtins.c:815
      From worker 14:	jl_f__apply_iterate at C:/workdir/src\builtins.c:823
      From worker 14:	invokelatest at .\essentials.jl:925
      From worker 14:	jl_fptr_args at C:/workdir/src\gf.c:2555
      From worker 14:	_jl_invoke at C:/workdir/src\gf.c:2894 [inlined]
      From worker 14:	ijl_apply_generic at C:/workdir/src\gf.c:3095
      From worker 14:	jl_apply at C:/workdir/src\julia.h:2129 [inlined]
      From worker 14:	do_apply at C:/workdir/src\builtins.c:815
      From worker 14:	jl_f__apply_iterate at C:/workdir/src\builtins.c:823
      From worker 14:	#110 at C:\workdir\usr\share\julia\stdlib\v1.11\Distributed\src\process_messages.jl:286
      From worker 14:	run_work_thunk at C:\workdir\usr\share\julia\stdlib\v1.11\Distributed\src\process_messages.jl:70
      From worker 14:	#109 at C:\workdir\usr\share\julia\stdlib\v1.11\Distributed\src\process_messages.jl:286
      From worker 14:	unknown function (ip: 134f51df)
      From worker 14:	_jl_invoke at C:/workdir/src\gf.c:2894 [inlined]
      From worker 14:	ijl_apply_generic at C:/workdir/src\gf.c:3095
      From worker 14:	jl_apply at C:/workdir/src\julia.h:2129 [inlined]
      From worker 14:	start_task at C:/workdir/src\task.c:1288
      From worker 14:	Allocations: 219769826 (Pool: 219752343; Big: 17483); GC: 97
reinterpretarray                                (14) |         failed at 2023-11-09T06:53:26.179

@vtjnash vtjnash requested a review from N5N3 November 9, 2023 14:24
@N5N3
Copy link
Member

N5N3 commented Nov 10, 2023

Looks quite unrelated?
It segfaulted in the most general branch, and the test code change seems also valid.

@vtjnash
Copy link
Member Author

vtjnash commented Nov 10, 2023

Yeah, that confuses me too, but I don't think we had seen this before. Perhaps it was something else recent though that led to different compilation?

@N5N3
Copy link
Member

N5N3 commented Nov 10, 2023

Confirmed that this segfaulting is reproducable without #44186.
Test MWE:

using Test, InteractiveUtils
struct TSlow{T,N} <: AbstractArray{T,N}
    data::Dict{NTuple{N,Int}, T}
    dims::NTuple{N,Int}
end
TSlow(::Type{T}, dims::NTuple{N,Int}) where {T,N} = TSlow{T,N}(Dict{NTuple{N,Int}, T}(), dims)
TSlow(X::AbstractArray{T,N}) where {T,N} = TSlow{T,N}(X)
TSlow{T,N}(X::AbstractArray     ) where {T,N  } = begin
    A = TSlow(T, size(X))
    for I in CartesianIndices(X)
        A[Tuple(I)...] = X[Tuple(I)...]
    end
    A
end

Base.size(A::TSlow) = A.dims
Base.getindex(A::TSlow{T,N}, i::Vararg{Int,N}) where {T,N} = get(A.data, i, zero(T))
Base.setindex!(A::TSlow{T,N}, v, i::Vararg{Int,N}) where {T,N} = (A.data[i] = v)

B = Complex{Int64}[5+6im, 7+8im, 9+10im]
function f(Bc)
    reinterpret(NTuple{3, Int64}, Bc)[2] = (4,5,6)
    @test Bc == Complex{Int64}[5+6im, 7+4im, 5+6im]
    B2 = reinterpret(NTuple{3, Int64}, Bc)
    @test setindex!(B2, (1,2,3), 1) === B2
end
versioninfo()
f(TSlow(B))

Result:

$ usr/bin/julia.exe -e "include(\"C:\\\\Users\\\\MYJ\\\\.envpack\\\\temp.jl\")"
Julia Version 1.11.0-DEV.862
Commit 8f8b9cacdf (2023-11-08 15:20 UTC)
Platform Info:
  OS: Windows (i686-w64-mingw32)
  CPU: 16 × 12th Gen Intel(R) Core(TM) i7-12650H
  WORD_SIZE: 32
  LLVM: libLLVM-15.0.7 (ORCJIT, alderlake)
  Threads: 8 on 12 virtual cores
Environment:
  JULIA_CPU_THREADS = 12
  JULIA_NUM_THREADS = 6

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x27a9c4f3 -- memcpy at .\cmem.jl:14 [inlined]
_setindex_ra! at .\reinterpretarray.jl:584 [inlined]
setindex! at .\reinterpretarray.jl:505 [inlined]
macro expansion at D:\Documents\GitHub\julia\julia-mingw-w32\usr\share\julia\stdlib\v1.11\Test\src\Test.jl:676 [inlined]
f at C:\Users\MYJ\.envpack\temp.jl:27
in expression starting at C:\Users\MYJ\.envpack\temp.jl:30
memcpy at .\cmem.jl:14 [inlined]
_setindex_ra! at .\reinterpretarray.jl:584 [inlined]
setindex! at .\reinterpretarray.jl:505 [inlined]
macro expansion at D:\Documents\GitHub\julia\julia-mingw-w32\usr\share\julia\stdlib\v1.11\Test\src\Test.jl:676 [inlined]
f at C:\Users\MYJ\.envpack\temp.jl:27
unknown function (ip: 27a9cb31)
_jl_invoke at /cygdrive/d/Documents/GitHub/julia/src\gf.c:2913 [inlined]
ijl_apply_generic at /cygdrive/d/Documents/GitHub/julia/src\gf.c:3095
jl_apply at /cygdrive/d/Documents/GitHub/julia/src\julia.h:2130 [inlined]
do_call at /cygdrive/d/Documents/GitHub/julia/src\interpreter.c:126
eval_value at /cygdrive/d/Documents/GitHub/julia/src\interpreter.c:223
eval_stmt_value at /cygdrive/d/Documents/GitHub/julia/src\interpreter.c:174 [inlined]
eval_body at /cygdrive/d/Documents/GitHub/julia/src\interpreter.c:641
jl_interpret_toplevel_thunk at /cygdrive/d/Documents/GitHub/julia/src\interpreter.c:795
jl_toplevel_eval_flex at /cygdrive/d/Documents/GitHub/julia/src\toplevel.c:938
jl_toplevel_eval_flex at /cygdrive/d/Documents/GitHub/julia/src\toplevel.c:881
ijl_toplevel_eval at /cygdrive/d/Documents/GitHub/julia/src\toplevel.c:947 [inlined]
ijl_toplevel_eval_in at /cygdrive/d/Documents/GitHub/julia/src\toplevel.c:989
eval at .\boot.jl:418 [inlined]
include_string at .\loading.jl:2133
jl_fptr_args at /cygdrive/d/Documents/GitHub/julia/src\gf.c:2555
_jl_invoke at /cygdrive/d/Documents/GitHub/julia/src\gf.c:2894 [inlined]
ijl_apply_generic at /cygdrive/d/Documents/GitHub/julia/src\gf.c:3095
_include at .\loading.jl:2193
include at .\sysimg.jl:38
unknown function (ip: 27a90071)
_jl_invoke at /cygdrive/d/Documents/GitHub/julia/src\gf.c:2913 [inlined]
ijl_apply_generic at /cygdrive/d/Documents/GitHub/julia/src\gf.c:3095
jl_apply at /cygdrive/d/Documents/GitHub/julia/src\julia.h:2130 [inlined]
do_call at /cygdrive/d/Documents/GitHub/julia/src\interpreter.c:126
eval_value at /cygdrive/d/Documents/GitHub/julia/src\interpreter.c:223
eval_stmt_value at /cygdrive/d/Documents/GitHub/julia/src\interpreter.c:174 [inlined]
eval_body at /cygdrive/d/Documents/GitHub/julia/src\interpreter.c:641
jl_interpret_toplevel_thunk at /cygdrive/d/Documents/GitHub/julia/src\interpreter.c:795
jl_toplevel_eval_flex at /cygdrive/d/Documents/GitHub/julia/src\toplevel.c:938
jl_toplevel_eval_flex at /cygdrive/d/Documents/GitHub/julia/src\toplevel.c:881
ijl_toplevel_eval at /cygdrive/d/Documents/GitHub/julia/src\toplevel.c:947 [inlined]
ijl_toplevel_eval_in at /cygdrive/d/Documents/GitHub/julia/src\toplevel.c:989
eval at .\boot.jl:418 [inlined]
exec_options at .\client.jl:291
_start at .\client.jl:525
jfptr__start_69683 at D:\Documents\GitHub\julia\julia-mingw-w32\usr\lib\julia\sys.dll (unknown line)
_jl_invoke at /cygdrive/d/Documents/GitHub/julia/src\gf.c:2894 [inlined]
ijl_apply_generic at /cygdrive/d/Documents/GitHub/julia/src\gf.c:3095
jl_apply at /cygdrive/d/Documents/GitHub/julia/src\julia.h:2130 [inlined]
true_main at /cygdrive/d/Documents/GitHub/julia/src\jlapi.c:586
jl_repl_entrypoint at /cygdrive/d/Documents/GitHub/julia/src\jlapi.c:738
jl_load_repl at /cygdrive/d/Documents/GitHub/julia/cli\loader_lib.c:569
mainCRTStartup at /cygdrive/d/Documents/GitHub/julia/cli\loader_exe.c:58
BaseThreadInitThunk at C:\Windows\System32\KERNEL32.DLL (unknown line)
RtlInitializeExceptionChain at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
RtlClearBits at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
Allocations: 1454771 (Pool: 1454720; Big: 51); GC: 4

@vtjnash vtjnash closed this Nov 10, 2023
@vtjnash vtjnash deleted the revert-44186-Contigious branch November 10, 2023 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants