Skip to content

Commit

Permalink
Always use %p for pointers in Crystal::System.print_error (crysta…
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil authored Jan 10, 2024
1 parent b56c7d9 commit 79b6e73
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/crystal/system/unix/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ module Crystal::System::Signal
if is_stack_overflow
Crystal::System.print_error "Stack overflow (e.g., infinite or very deep recursion)\n"
else
Crystal::System.print_error "Invalid memory access (signal %d) at address 0x%lx\n", sig, addr
Crystal::System.print_error "Invalid memory access (signal %d) at address %p\n", sig, addr
end

Exception::CallStack.print_backtrace
Expand Down
2 changes: 1 addition & 1 deletion src/exception/call_stack/libunwind.cr
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct Exception::CallStack
end

private def self.print_frame(repeated_frame)
Crystal::System.print_error "[0x%llx] ", repeated_frame.ip.address.to_u64
Crystal::System.print_error "[%p] ", repeated_frame.ip.address
print_frame_location(repeated_frame)
Crystal::System.print_error " (%d times)", repeated_frame.count + 1 unless repeated_frame.count == 0
Crystal::System.print_error "\n"
Expand Down
4 changes: 2 additions & 2 deletions src/exception/call_stack/stackwalk.cr
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct Exception::CallStack
case exception_info.value.exceptionRecord.value.exceptionCode
when LibC::EXCEPTION_ACCESS_VIOLATION
addr = exception_info.value.exceptionRecord.value.exceptionInformation[1]
Crystal::System.print_error "Invalid memory access (C0000005) at address 0x%llx\n", addr
Crystal::System.print_error "Invalid memory access (C0000005) at address %p\n", Pointer(Void).new(addr)
print_backtrace(exception_info)
LibC._exit(1)
when LibC::EXCEPTION_STACK_OVERFLOW
Expand Down Expand Up @@ -150,7 +150,7 @@ struct Exception::CallStack
end

private def self.print_frame(repeated_frame)
Crystal::System.print_error "[0x%llx] ", repeated_frame.ip.address.to_u64
Crystal::System.print_error "[%p] ", repeated_frame.ip.address
print_frame_location(repeated_frame)
Crystal::System.print_error " (%d times)", repeated_frame.count + 1 unless repeated_frame.count == 0
Crystal::System.print_error "\n"
Expand Down

0 comments on commit 79b6e73

Please sign in to comment.