Skip to content
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

Bus error from string(typeof(x)) inside JSON.lower #34249

Closed
yurivish opened this issue Jan 3, 2020 · 3 comments
Closed

Bus error from string(typeof(x)) inside JSON.lower #34249

yurivish opened this issue Jan 3, 2020 · 3 comments

Comments

@yurivish
Copy link
Contributor

yurivish commented Jan 3, 2020

This is the best minimal example I've come up with so far. It happens reliably.

julia> using JSON, NamedTupleTools
julia> JSON.lower(x) = (type=string(typeof(x)), ntfromstruct(x)...)
julia> struct Foo end
julia> JSON.json(Foo())
(v1.3) pkg> status
    Status `~/.julia/environments/v1.3/Project.toml`
  ...
  [682c06a0] JSON v0.21.0
  [d9ec5142] NamedTupleTools v0.12.1
  ...

julia> versioninfo()
Julia Version 1.3.1
Commit 2d5741174c (2019-12-30 21:36 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.6.0)
  CPU: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

If you change the JSON.lower definition to the below then it no longer crashes but correctly runs forever due to the recursion (this is supposed to run forever since lower returns a NamedTuple, which itself needs to be lowered):

julia> JSON.lower(x) = (type=string(typeof(x)), fields=ntfromstruct(x))
^CERROR: InterruptException:
Stacktrace:
 [1] lower(::NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields),Tuple{String,NamedTuple{(:type, :fields), ...
@yurivish yurivish changed the title Bus error when accessing typeof(x).name inside recursive JSON.lower Bus error from string(typeof(x)) inside JSON.lower Jan 3, 2020
@JeffBezanson
Copy link
Member

I think this is just a stackoverflow --- I get a stack overflow error on Linux.

@yurivish
Copy link
Contributor Author

yurivish commented Jan 3, 2020

On macOS Catalina 10.15.1 (19B2106) I definitely get a bus error:

julia> using JSON, NamedTupleTools

julia> JSON.lower(x) = (type=string(typeof(x)), ntfromstruct(x)...)

julia> struct Foo end

julia> JSON.json(Foo())
zsh: bus error  julia

@JeffBezanson
Copy link
Member

Probably a duplicate of #17109. This appears to be a mac os issue we've never been able to resolve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants