Skip to content

runtime: signal handling: cgoSigtramp fails to save C callee-save registers. #18328

Closed
@bcmills

Description

@bcmills

In programs using cgo, runtime.setsig registers runtime.cgoSigtramp as the handler for signals to the runtime. cgoSigtramp calls sigtramp, which calls sigtrampgo, which uses the Go calling convention. The Go convention treats all registers except the stack pointer and frame pointer as caller-save (#16922).

In debugging #17641, I noticed that cgoSigtramp does not save the C callee-save registers before invoking those Go functions. If the call to the Go handler is forwarded through other C handlers (as in the case of TSAN interceptors; see #18255), that potentially results in corruption of the register contents and undefined behavior when control returns to the C caller.

I am attempting to write a reproducible test-case and will post it here as an update.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions