Skip to content

Swift crash handler reads si_addr for signals where it is not guaranteed to be filled #80730

Open
@rjmansfield

Description

@rjmansfield

Description

The crash handler will report the program faulted at si_addr, however si_addr is not filled for all signals, for example, SIGQUIT, SIGABORT. This leads to reporting a misleading message where the address is not valid.

crashInfo.fault_address = (uint64_t)pinfo->si_addr;

According to POSIX si_addr may be filled for SIGILL, SIGFPE, SIGSEGV and SIGBUS

https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/signal.h.html

For some implementations, the value of si_addr may be inaccurate.

Reproduction

$ cat abort.swift 
import Glibc

abort()
$ ./abort

💣 Program crashed: Aborted at 0x3a07e15300047ea1

Thread 0 "abort" crashed:

0 0x00007f436bb4b9fc pthread_kill@@GLIBC_2.34 + 300 in libc.so.6

where 0x3a07e15300047ea1 is not a valid instruction.

Expected behavior

Not printing a misleading fault address. Perhaps the pc could be read from the ucontext

Environment

$ swiftc -v
Swift version 6.2-dev (LLVM 2e7485f44847d34, Swift 1e96466)

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.runtimeThe Swift Runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions