-
-
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
Ensure immutable isbits Union fields get set correctly #23367
Conversation
Ok, a little more sleuthing:
I'm not quite sure what the right solution here is though. Modify I feel like there still might be another issue going on, because in the llvm code for |
src/builtins.c
Outdated
@@ -259,6 +259,10 @@ JL_CALLABLE(jl_f_sizeof) | |||
jl_value_t *x = args[0]; | |||
if (jl_is_unionall(x) || jl_is_uniontype(x)) { | |||
x = jl_unwrap_unionall(x); | |||
size_t elsize = 0, al = 0; | |||
int isinline = jl_islayout_inline(x, &elsize, &al); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will have the curious property that T == S
will not imply sizeof(T) == sizeof(S)
. I'm not sure if that's going to be an issue, but it does make be nervous. In particular, consider Union{Tuple{Int64}, Tuple{Int8}}
, which doesn't include selector bits, vs. Tuple{Union{Int64, Int8}}
, which throws an error.
Bump @vtjnash, I could really use your help/direction here. |
Alright, added some tests for @vtjnash's help w/ the fix. Let's see what CI says. Anyone else want to take a look? |
That's a lot of great green checkmarks; a shame that Travis is backed up so far. |
Looks like Travis caught another bug though:
(that line is assuming isbits_layout === isdatatype) |
Mac failure is #23215; everything else looks all good. |
16863b9
to
7cf7580
Compare
@vtjnash is this good to go? |
depth); | ||
jl_datatype_t *ft = (jl_datatype_t*)jl_field_type(vt, i); | ||
if (jl_is_uniontype(ft)) { | ||
uint8_t sel = ((uint8_t*)fld_ptr)[jl_field_size(vt, i) - 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This operation should be abstracted.
I'm still seeing a segfault w/ struct A
x::Union{Float64, Void}
end
getx(a::A) = a.x
getx(A(1.0)) |
Ok, looks like the segfault is coming from
when I also see
I'm not really sure what needs to be done here though. |
7cf7580
to
4a5e85d
Compare
Hmmm, travis linux 64-bit & julia freebsd ci both stalled during tests; I imagine unrelated? Have we seen those kinds of hangs elsewhere? |
Yes, I've seen a hang today in another PR. |
When the new gc root placement pass was introduced, the .gcroot field lost its original meaning and became mostly superfluous. However, the codegen code for unions still used it to get a referenced to the boxed part of the split union. Clean that up by introducing an explicit field for that purpose and removing the .gcroot field.
anonymize all types, remove special representation for Ptr, fix Constant generation for types containing split-union fields
4a5e85d
to
2bb430e
Compare
Ok, rebased this again on top of @Keno 's new gcroot commit. Also added a test for the codgen-getfield crash I saw above. Let's see what CI says on all of this. |
CI->getType(), "", CI); | ||
ASCI->takeName(CI); | ||
CI->replaceAllUsesWith(ASCI); | ||
auto *ptr = new PtrToIntInst(CI->getOperand(0), CI->getType(), "", CI); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't valid by IR invariants (it'll complain on LLVM 5.0+). Why does this need to be an int?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what CI->getType() is. We can worry about LLVM 5 when we start supporting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yuyichao is running in that configuration AFAIK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 4.0 already has non-integral pointer so this will complain there already.
I'm on 4.0 but I do test svn from time to time to make sure it's ready whenever Arch's package is updated.
Should be enough to just keep the old addrspacecast
and add an ptrtoint
on top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not addressed and it breaks LLVM 4.0 .
@@ -76,6 +76,8 @@ end | |||
a = Base.cconvert(Ptr{LibGit2.StrArrayStruct}, p) | |||
b = Base.unsafe_convert(Ptr{LibGit2.StrArrayStruct}, a) | |||
@test p == convert(Vector{String}, unsafe_load(b)) | |||
@noinline gcuse(a) = a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use Core.gcuse
now.
❤️ |
This breaks
As seen on LLVM.jl, bisected to 1875957. |
llvmcall is still experimental (unstable) anyways |
Yeah sure stuff breaks on master all the time, just reporting the fact. |
OK, so looking at the actual commits this seems fully intended. Is this anonymization of pointers to native-width integers going to be the default from now on? |
@vtjnash, this isn't quite right yet. When constructed, the selector byte and any non-union fields aren't getting set correctly.
I'm kind of just taking a stab here, and I'm guessing that my use of
fval_info
anddest
are not quite right, hence the non-working solution here. For example, when I runthe
fval_info
isI'm not sure why the
fval_info.constant
isn't set, but that causes problems when we try tocompute_tindex_unboxed
later againstBitsUnion
.I won't be able to do much else on this for the rest of the day, but any pointers/tips/direction you or @yuyichao could provide would be much appreciated.
fix #23351