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

abstract + Serializable + useless property = Invalid memory access #10541

Closed
636f7374 opened this issue Mar 23, 2021 · 1 comment
Closed

abstract + Serializable + useless property = Invalid memory access #10541

636f7374 opened this issue Mar 23, 2021 · 1 comment

Comments

@636f7374
Copy link

636f7374 commented Mar 23, 2021

Summary

  • This bug was accidentally triggered during testing.
  • abstract + Serializable + useless property = Invalid memory access.
  • Maybe there should be a better title.
    • (But I don’t know how to describe it better).

Example

require "json"

abstract struct Frames
  include JSON::Serializable

  property frameType : String
end

abstract struct Frames
  struct Assign < Frames
    property createdAt : Time

    def initialize
      @createdAt = Time.local
      @stepType = "assign"
    end
  end
end

assign = Frames::Assign.new

Verbose

Invalid memory access (signal 11) at address 0xc
[0x108a46abb] *Exception::CallStack::print_backtrace:(Int32 | Nil) +107
[0x108a18ce4] __crystal_sigfault_handler +292
[0x7fff71ce25fd] _sigtramp +29
[0x108a5036a] *Pointer(UInt8)@Pointer(T)#[]<Int32>:UInt8 +10
[0x108a4ebbe] *Char::Reader#byte_at<Int32>:UInt32 +30
[0x108a4da74] *Char::Reader#decode_current_char:Char +36
[0x108a4da47] *Char::Reader#initialize<String, Int32>:Char +87
[0x108a4d9e7] *Char::Reader#initialize<String>:Char +39
[0x108a4d966] *Char::Reader::new<String>:Char::Reader +102
[0x108a2cbb4] *String#inspect<String::Builder>:Nil +84
[0x108b41f4a] *Frames::Assign@Struct#inspect<String::Builder>:Nil +90
[0x108b41ed2] *Frames::Assign@Object#inspect:String +66
[0x108b2862a] *Crystal::Playground::Agent#to_value<Frames::Assign>:String +74
[0x108b285a8] *Crystal::Playground::Agent#safe_to_value<Frames::Assign>:String +104
[0x108a04cd0] __crystal_main +2064
[0x108b4c0c4] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +36
[0x108b4bf3b] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +43
[0x108a105f9] main +9

exit status: 11

Version

$ crystal -v
Crystal 1.0.0 (2021-03-22)

LLVM: 9.0.1
Default target: x86_64-apple-macosx

$ uname -a
Darwin iMac.local 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64
@asterite
Copy link
Member

Duplicate of #9775

@asterite asterite marked this as a duplicate of #9775 Mar 23, 2021
@Blacksmoke16 Blacksmoke16 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants