-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
regressionRegression in behavior compared to a previous versionRegression in behavior compared to a previous version
Milestone
Description
The following code fails with an UndefRefError on Julia 1.7:
struct BadStruct{R,S}
named_tuple::NamedTuple{R,S}
n::Int
end
BadStruct(NamedTuple{}(), 0)It also exits the REPL.
I'm not sure what's going on here, but here are some observations:
- I can't reproduce the error with only the named tuple in the struct.
- With no type parameters (R, S), there's no crash.
- When the Named Tuple is nonempty, there's no crash.
- The construction of the struct succeeds, because
let x = BadStruct(NamedTuple{}(), 0); x.n endworks. Butlet x = BadStruct(NamedTuple{}(), 0); x.named_tuple endraises the UndefRefError, this time in Base.getproperty. So it seems the struct is being constructed, but thenamed_tuplefield is not getting initialized properly? Note this example gives an error but does not kill the REPL. - This is possibly related to Wrapping NamedTuple in struct is no longer bitstype in 1.7 #43411.
My versioninfo() is
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
OS: macOS (arm64-apple-darwin21.2.0)
CPU: Apple M1 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, cyclone)
but @femtomc has reproduced the error, with
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake-avx512)
Environment:
JULIA_VERSION = 1.6.1
This issue came up because Gen.jl's StaticChoiceMap datatype is similar to the BadStruct above, and we noticed crashes when upgrading to Julia 1.7. (https://github.com/probcomp/Gen.jl/blob/44f5f1408caf05ff95932bb58d9f57907c5084e3/src/choice_map.jl#L350).
The code works fine on my machine on Julia 1.6.3.
Thanks!
femtomc and t-bltg
Metadata
Metadata
Assignees
Labels
regressionRegression in behavior compared to a previous versionRegression in behavior compared to a previous version