- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 end
works. Butlet x = BadStruct(NamedTuple{}(), 0); x.named_tuple end
raises the UndefRefError, this time in Base.getproperty. So it seems the struct is being constructed, but thenamed_tuple
field 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
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]Packing two NamedTuples into a struct causes `UndefRefError: access to undefined reference` (Julia 1.7)[/-][+]Packing one empty and one non-empty NamedTuple into a struct causes `UndefRefError: access to undefined reference` (Julia 1.7)[/+][-]Packing one empty and one non-empty NamedTuple into a struct causes `UndefRefError: access to undefined reference` (Julia 1.7)[/-][+]Packing an empty NamedTuple into a struct with other elements causes `UndefRefError: access to undefined reference` (Julia 1.7)[/+]femtomc commentedon Jan 12, 2022
Here's an additional yikes:
femtomc commentedon Jan 13, 2022
Is this #40947 from Tim's comment on #43411 (?)
JeffBezanson commentedon Feb 23, 2022
Also fixed by #44311, so yes I think this is a duplicate of #43411.
pf_initialize
probcomp/GenParticleFilters.jl#5