-
-
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
Illegal instruction crash on 1.7 #44921
Comments
This is the smallest MWE I can come up with. module Foo
Base.@kwdef struct Options
order::Symbol = :declared
addprocs_machines = []
addprocs_kwargs = []
end
abstract type ExecutionTreeNode end
const AllExecutionTreeNodeTypes = Union{ExecutionTreeNode,LineNumberNode}
struct Inner <: ExecutionTreeNode
test_options::Options
end
struct Outer{T<:AllExecutionTreeNodeTypes}
data::T
children::Vector
end
abstract type TestNodeTrait end
struct IsKnownAtParseTime{T<:TestNodeTrait}
trait::T
end
struct IsUnknownAtParseTime{T<:TestNodeTrait}
trait::T
end
struct OrderTrait end
struct DeclaredOrder <: TestNodeTrait end
struct NumberedOrder <: TestNodeTrait end
struct ProcessParallelOrder <: TestNodeTrait end
function OrderTrait(tree)
options = tree.data.test_options
return if options.order == :declared
IsKnownAtParseTime(DeclaredOrder())
elseif options.order == :numbered
IsKnownAtParseTime(NumberedOrder())
elseif options.order == :process_parallel
resolve_trait(tree, ProcessParallelOrder, [:addprocs_machines, :addprocs_kwargs])
else
error("")
end
end
function resolve_trait(tree, trait_type, fields)
return if options_unknown_at_parse_time(tree, fields)
IsUnknownAtParseTime(trait_type())
else
IsKnownAtParseTime(trait_type())
end
end
function options_unknown_at_parse_time(tree, fields)
options = tree.data.test_options
any_unknown = any(field -> pred(getproperty(options, field)), fields)
return any_unknown
end
pred(it) = it isa Expr
end
import Test
Test.@testset "foo" begin
Test.@test Foo.IsKnownAtParseTime(Foo.ProcessParallelOrder()) ==
Foo.OrderTrait(Foo.Outer(Foo.Inner(Foo.Options(order = :process_parallel)), []))
end
This is an interesting example. You can get this code to produce other illegal instruction crashes by tweaking it; the type parameters on the structs are particularly effective. You can also fix the crashes by making other small changes. Try reducing the number of branches in the conditionals inside the |
Reduced to: struct a{b}
c::b
end
function d(e)
if e == :x
a(f)
elseif e == :p
g(e)
end
end
function g(e)
if !any([])
a(())
end
end
d(:p) |
@maleadt what's Edit: ok, it's undefined, I guess that's kinda part of the reproducer. |
This happens on macos too. it crashes on x86 and hangs on m1. It hangs on |
We added a diff --git a/src/codegen.cpp b/src/codegen.cpp
index 7bd2be612e..85051b501a 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -1867,14 +1867,15 @@ static jl_cgval_t convert_julia_type_union(jl_codectx_t &ctx, const jl_cgval_t &
boxv = ctx.builder.CreateSelect(
ctx.builder.CreateAnd(wasboxed, isboxed), v.Vboxed, boxv);
}
+ Value *slotv;
+ MDNode *tbaa;
if (v.V == NULL) {
// v.V might be NULL if it was all ghost objects before
- return jl_cgval_t(boxv, NULL, false, typ, new_tindex, ctx.tbaa());
+ slotv = NULL;
+ tbaa = ctx.tbaa().tbaa_const;
}
else {
Value *isboxv = ctx.builder.CreateIsNotNull(boxv);
- Value *slotv;
- MDNode *tbaa;
if (v.ispointer()) {
slotv = v.V;
tbaa = v.tbaa;
@@ -1887,12 +1888,12 @@ static jl_cgval_t convert_julia_type_union(jl_codectx_t &ctx, const jl_cgval_t &
slotv = ctx.builder.CreateSelect(isboxv,
decay_derived(ctx, boxv),
decay_derived(ctx, emit_bitcast(ctx, slotv, boxv->getType())));
- jl_cgval_t newv = jl_cgval_t(slotv, NULL, false, typ, new_tindex, ctx.tbaa());
- assert(boxv->getType() == ctx.types().T_prjlvalue);
- newv.Vboxed = boxv;
- newv.tbaa = tbaa;
- return newv;
}
+ jl_cgval_t newv = jl_cgval_t(slotv, NULL, false, typ, new_tindex, ctx.tbaa());
+ assert(boxv->getType() == ctx.types().T_prjlvalue);
+ newv.Vboxed = boxv;
+ newv.tbaa = tbaa;
+ return newv;
}
}
else { |
I experienced a crash due to
signal (4): Illegal instruction
:I have uploaded an rr trace of this crash here.
versioninfo:
This also happens on the latest commit
The text was updated successfully, but these errors were encountered: