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

IO::Memory.write_bytes IO::ByteFormat::BigEndian triggers Invalid memory access #10396

Closed
636f7374 opened this issue Feb 14, 2021 · 4 comments
Closed

Comments

@636f7374
Copy link

Summary

  • I accidentally triggered this problem while modifying the code.
  • Reproducible.

Sample

  • Code
damage_slice = "\xd1\x8c\x81\x80\x00\x01\x00\x02".to_slice
damage_io = IO::Memory.new damage_slice
ttl = damage_io.read_bytes UInt32, IO::ByteFormat::BigEndian
damage_io.write_bytes ttl, IO::ByteFormat::BigEndian
  • Verbose
Output
Invalid memory access (signal 10) at address 0x10c8ccbd0
[0x10c7967e6] *Exception::CallStack::print_backtrace:(Int32 | Nil) +118
[0x10c763eee] __crystal_sigfault_handler +318
[0x7fff70cb75fd] _sigtramp +29

exit status: 10

System Information

$ crystal -v
Crystal 0.36.1 (2021-02-02)

LLVM: 11.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
@oprypin
Copy link
Member

oprypin commented Feb 14, 2021

I think this is #10362

@636f7374
Copy link
Author

@oprypin Okay :)

@oprypin
Copy link
Member

oprypin commented Feb 14, 2021

Yes, it is. On master it produces Unhandled exception: Read-only stream (IO::Error).
This will not be "fixed" but the error has been made explicit. You are trying to write to a buffer that's based on read-only memory.
I recommend closing this.

@straight-shoota
Copy link
Member

Duplicate of #10362

@straight-shoota straight-shoota marked this as a duplicate of #10362 Feb 14, 2021
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