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

StackOverflowError when printing self-referential struct #33392

Closed
HFriberg opened this issue Sep 26, 2019 · 3 comments
Closed

StackOverflowError when printing self-referential struct #33392

HFriberg opened this issue Sep 26, 2019 · 3 comments

Comments

@HFriberg
Copy link

I expected the following code

mutable struct node_t
    prev::node_t
    next::node_t
end

x = Vector{node_t}(undef,3);
show(x)  # StackOverflowError

to produce the output

node_t[#undef, #undef, #undef]

but instead it recursed forever until the stack was full.

Bonus info: Adding an unused(?) inner constructor:

mutable struct node_t
    prev::node_t
    next::node_t
    node_t() = new()    # not used anywhere??
end

x = Vector{node_t}(undef,3);
show(x)

makes it behave as expected.

@jpsamaroo
Copy link
Member

I can't reproduce this locally, what version of Julia are you on?

julia> mutable struct node_t
           prev::node_t
           next::node_t
       end

julia> x = Vector{node_t}(undef,3);

julia> show(x)  # StackOverflowError
node_t[#undef, #undef, #undef]
julia> versioninfo()
Julia Version 1.3.0-alpha.105
Commit 6527de0c0f (2019-08-12 22:31 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)
Environment:
  JULIA_REVISE_POLL = 1
  JULIA_LOAD_PATH = @dev:@:@v#.#:@stdlib
  JULIA_PKG3_PRECOMPILE = 1

@JeffBezanson
Copy link
Member

I believe this is a dup of #31064 which is fixed in 1.3.

@HFriberg
Copy link
Author

@JeffBezanson is correct.

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

3 participants