diff options
author | Fabricio Voznika <fvoznika@google.com> | 2019-03-05 22:19:23 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-03-05 22:20:17 -0800 |
commit | fcba4e8f040ab4b40e04b9315d718d7e5aa44635 (patch) | |
tree | 4b33e78a90d5d3f8de8e98faa79660bbc6e94146 /runsc/boot/compat.go | |
parent | 1718fdd1a8e16f36433b069a0f5d88ea7bdb65f5 (diff) |
Add uncaught signal message to the user log
This help troubleshoot cases where the container is killed and the
app logs don't show the reason.
PiperOrigin-RevId: 236982883
Change-Id: I361892856a146cea5b04abaa3aedbf805e123724
Diffstat (limited to 'runsc/boot/compat.go')
-rw-r--r-- | runsc/boot/compat.go | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/runsc/boot/compat.go b/runsc/boot/compat.go index 572b5b472..37d0c31fd 100644 --- a/runsc/boot/compat.go +++ b/runsc/boot/compat.go @@ -26,6 +26,7 @@ import ( "gvisor.googlesource.com/gvisor/pkg/log" "gvisor.googlesource.com/gvisor/pkg/sentry/arch" rpb "gvisor.googlesource.com/gvisor/pkg/sentry/arch/registers_go_proto" + ucspb "gvisor.googlesource.com/gvisor/pkg/sentry/kernel/uncaught_signal_go_proto" "gvisor.googlesource.com/gvisor/pkg/sentry/strace" spb "gvisor.googlesource.com/gvisor/pkg/sentry/unimpl/unimplemented_syscall_go_proto" ) @@ -73,12 +74,18 @@ func newCompatEmitter(logFD int) (*compatEmitter, error) { } // Emit implements eventchannel.Emitter. -func (c *compatEmitter) Emit(msg proto.Message) (hangup bool, err error) { - // Only interested in UnimplementedSyscall, skip the rest. - us, ok := msg.(*spb.UnimplementedSyscall) - if !ok { - return false, nil +func (c *compatEmitter) Emit(msg proto.Message) (bool, error) { + switch m := msg.(type) { + case *spb.UnimplementedSyscall: + c.emitUnimplementedSyscall(m) + case *ucspb.UncaughtSignal: + c.emitUncaughtSignal(m) } + + return false, nil +} + +func (c *compatEmitter) emitUnimplementedSyscall(us *spb.UnimplementedSyscall) { regs := us.Registers.GetArch().(*rpb.Registers_Amd64).Amd64 c.mu.Lock() @@ -113,7 +120,13 @@ func (c *compatEmitter) Emit(msg proto.Message) (hangup bool, err error) { c.sink.Infof("Unsupported syscall: %s, regs: %+v", c.nameMap.Name(uintptr(sysnr)), regs) tr.onReported(regs) } - return false, nil +} + +func (c *compatEmitter) emitUncaughtSignal(msg *ucspb.UncaughtSignal) { + sig := syscall.Signal(msg.SignalNumber) + c.sink.Infof( + "Uncaught signal: %q (%d), PID: %d, TID: %d, fault addr: %#x", + sig, msg.SignalNumber, msg.Pid, msg.Tid, msg.FaultAddr) } // Close implements eventchannel.Emitter. |