Skip to content

Segfault/assertion failure/IR verification error due to non-dominated use of SSAValue #46408

Closed

Description

As seen on PkgEval:

[15] signal (11): Segmentation fault
in expression starting at /home/pkgeval/.julia/packages/Gnuplot/Iz8LH/test/runtests.jl:72
jl_iintrinsic_2 at /cache/build/default-amdci5-1/julialang/julia-master/src/runtime_intrinsics.c:985
<= at ./int.jl:488 [inlined]
in at ./range.jl:1413 [inlined]
map at ./tuple.jl:299 [inlined]
iterate at ./multidimensional.jl:396 [inlined]
arrays2datablock at /home/pkgeval/.julia/packages/Gnuplot/Iz8LH/src/Gnuplot.jl:430

Looking at the rr trace, turns out we're passing garbage into sle_int:

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007fee329f6c71 in jl_iintrinsic_2 (a=0x7fee2c5f2060, b=0x3, name=0x7fee32b92e15 "sle_int", lambda2=0x7fee329f5860 <jl_intrinsiclambda_cmp>, list=0x7fee32c412a0 <sle_int_list>, cvtb=0, getsign=0x7fee329f5840 <signbitbyte>) at /cache/build/default-amdci5-1/julialang/julia-master/src/runtime_intrinsics.c:985
985	    jl_value_t *tyb = jl_typeof(b);
(rr) p b
$7 = (jl_value_t *) 0x3
L3208:                                            ; preds = %L3207
  %3973 = call {} addrspace(10)* @jl_sle_int({} addrspace(10)* addrspacecast ({}* inttoptr (i64 140660923375712 to {}*) to {} addrspace(10)*), {} addrspace(10)* undef), !dbg !3060
  %3974 = bitcast {} addrspace(10)* %3973 to i8 addrspace(10)*, !dbg !3063
  %3975 = load i8, i8 addrspace(10)* %3974, align 1, !dbg !3063, !tbaa !3064, !range !3065
  %3976 = trunc i8 %3975 to i1, !dbg !3063
  %3977 = and i1 true, %3976, !dbg !3063
  %3978 = call {} addrspace(10)* @jl_sle_int({} addrspace(10)* addrspacecast ({}* inttoptr (i64 140660923375712 to {}*) to {} addrspace(10)*), {} addrspace(10)* undef), !dbg !3060
  %3979 = bitcast {} addrspace(10)* %3978 to i8 addrspace(10)*, !dbg !3063
  %3980 = load i8, i8 addrspace(10)* %3979, align 1, !dbg !3063, !tbaa !3064, !range !3065
  %3981 = trunc i8 %3980 to i1, !dbg !3063
  %3982 = and i1 true, %3981, !dbg !3063
  %3983 = and i1 %3977, %3982, !dbg !3066
  %3984 = xor i1 %3983, true, !dbg !3059
  %3985 = zext i1 %3984 to i8, !dbg !3057
  %3986 = trunc i8 %3985 to i1, !dbg !3057
  %3987 = xor i1 %3986, true, !dbg !3057
  br i1 %3987, label %L3216, label %L3215, !dbg !3057

Note the undef arguments.

Running the above under an assertions build reveals a failed assertion that can be reduced to:

using InteractiveUtils

function e(a::Vararg)
    b = 0
    for c in a
        0 && (b = c)
        if for d in CartesianIndices(a[b]) end
            for d in CartesianIndices(size(b)) end
        end
    end
end

code_llvm(e, Tuple{Array{Int64, 3}, Array{Int64, 2}})
julia: /home/tim/Julia/src/julia/src/codegen.cpp:4573: void emit_ssaval_assign(jl_codectx_t&, ssize_t, jl_value_t*): Assertion `!ctx.ssavalue_assigned.at(ssaidx_0based)' failed.

Bisected to #44557, so cc @ianatol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    compiler:codegenGeneration of LLVM IR and native coderegressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions