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

Invalid memory access (signal 11) at address 0x0 #7741

Closed
Blacksmoke16 opened this issue May 6, 2019 · 2 comments · Fixed by #7801
Closed

Invalid memory access (signal 11) at address 0x0 #7741

Blacksmoke16 opened this issue May 6, 2019 · 2 comments · Fixed by #7801
Assignees
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic

Comments

@Blacksmoke16
Copy link
Member

Extracted from #7728

https://play.crystal-lang.org/#/r/6u14/edit

abstract struct ColumnBase; end

record ColumnInfo(T, M) < ColumnBase, column_name : String, default : T? = nil, type : T.class = T do
  # Returns the SQL representation for this column.
  def to_column(io : IO) : Nil
  end
end

cols = [
  ColumnInfo(String, Int32).new("name", "Jim"),
  ColumnInfo(Int32, Int32).new("age", 123),
  ColumnInfo(Array(Bool), Int32).new("values", [true, false, false, true, true]),
  ColumnInfo(Int64, Int32).new("id", nil),
]

io = IO::Memory.new

cols.sort_by { |c| true ? -1 : 1 }.each &.to_column io
ColumnInfo(Time, Int32).new("created_at", nil).to_column io
Invalid memory access (signal 11) at address 0x0
[0x55af537d7006] *CallStack::print_backtrace:Int32 +118
[0x55af537c9e90] __crystal_sigfault_handler +192
[0x7f82cf1b93c0] ???
[0x0] ???

Same error against crystal master.

I was able to reduce it a bit, however the stack trace changed a bit.

https://play.crystal-lang.org/#/r/6ujl

abstract struct ColumnBase; end

record ColumnInfo(T) < ColumnBase, column_name : String, default : T? = nil

cols = [
  ColumnInfo(String).new("name"),
  ColumnInfo(Int32).new("age"),
  ColumnInfo(Array(Bool)).new("values"),
  ColumnInfo(Int32).new("id"),
]

io = IO::Memory.new

cols.sort_by { |c| true ? -1 : 1 }.each &.to_s io
ColumnInfo(Time?).new("created_at").to_s io
Invalid memory access (signal 11) at address 0x0
[0x563058616686] *CallStack::print_backtrace:Int32 +118
[0x563058608bc0] __crystal_sigfault_handler +192
[0x7f76ae0be3c0] ???
[0x56305861f926] *Slice(T)::new:read_only<Pointer(UInt8), Int32, Bool>:Slice(UInt8) +22
[0x563058619215] *String#to_slice:Slice(UInt8) +37
[0x56305861ca38] *String#to_s<IO::Memory>:Nil +24
[0x563058662961] *IO::Memory +17
[0x563058668bc0] *ColumnBase+ +32
[0x0] ???
@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic labels May 6, 2019
@Blacksmoke16
Copy link
Member Author

Blacksmoke16 commented May 20, 2019

Reduced some more

abstract struct ColumnBase; end

record ColumnInfo(T, M) < ColumnBase, default : T? = nil

cols = [
  ColumnInfo(String, Int32).new("Jim"),
  ColumnInfo(Int32, Int32).new(123),
  ColumnInfo(Array(Bool), Int32).new([true, false, false, true, true]),
]

c = cols.dup

c.each &.to_s

ColumnInfo(Time, Int32).new
Invalid memory access (signal 11) at address 0x0
[0x1065f0b6b] *CallStack::print_backtrace:Int32 +107
[0x1065d5ce5] __crystal_sigfault_handler +181
[0x106653533] sigfault_handler +35
[0x7fff77c5fb3d] _sigtramp +29
[0x1065f3788] *Slice(T)::new:read_only<Pointer(UInt8), Int32, Bool>:Slice(UInt8) +24
[0x1065d6ea9] *String#to_slice:Slice(UInt8) +41
[0x1065d6e49] *String#to_s<String::Builder>:Nil +25
[0x1065f2c68] *String::Builder@IO#<<<String>:String::Builder +24
[0x10663c192] *ColumnBase+@Struct#inspect<String::Builder>:Nil +34

@asterite
Copy link
Member

I have a fix, I'll send it later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants