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

segment fault while overwriting existing function in a module #32275

Closed
Roger-luo opened this issue Jun 10, 2019 · 4 comments
Closed

segment fault while overwriting existing function in a module #32275

Roger-luo opened this issue Jun 10, 2019 · 4 comments

Comments

@Roger-luo
Copy link
Contributor

I got this while trying to overwrite the getindex function in BitBasis.jl, it can be re-produced by the following code

using BitBasis

struct SubBit{T, L}
    parent::BitStr{T, L}
    index::Int
end

Base.getindex(x::BitStr, index::Int) = SubBit(x, index)

Then type

bit"101"[1]

in REPL will get this segmentation fault. Not sure why, if I remove the overloading of getindex inside BitBasis then it is fine.

versioninfo

julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.5.0)
  CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = code
@fredrikekre
Copy link
Member

This is what I get on Julia 1.0, 1.1, 1.2 and master:

julia> bit"101"[1]
SubBit{Int64,3}(101 (5), 1)

@Roger-luo
Copy link
Contributor Author

Roger-luo commented Jun 10, 2019

strange, I can still repeat this segmentfault on my laptop

image

what's your versioninfo()? maybe a Mac OS issue? Or try using BitBasis#master ?

@vtjnash
Copy link
Member

vtjnash commented Jun 10, 2019

Looks like a duplicate of #28577 (stack overflow may lead to segfault), since you appear to have defined that show(io, x::SubBit) = show(io, x)

@Roger-luo
Copy link
Contributor Author

Oh I see. Yes, it is a dup of it. Thanks!

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