From 78ecdfe18e43b7526afde7ec47fdabbd7f10926f Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Tue, 22 Mar 2016 15:41:49 -0700 Subject: [PATCH] Show proper error from init process panic Signed-off-by: Tonis Tiigi --- libcontainer/factory_linux.go | 8 ++++++++ libcontainer/process_linux.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go index 3a0ad81e..e67b001f 100644 --- a/libcontainer/factory_linux.go +++ b/libcontainer/factory_linux.go @@ -9,6 +9,7 @@ import ( "os/exec" "path/filepath" "regexp" + "runtime/debug" "strconv" "syscall" @@ -248,6 +249,13 @@ func (l *LinuxFactory) StartInitialization() (err error) { // ensure that this pipe is always closed pipe.Close() }() + + defer func() { + if e := recover(); e != nil { + err = fmt.Errorf("panic from initialization: %v, %v", e, string(debug.Stack())) + } + }() + i, err = newContainerInit(it, pipe) if err != nil { return err diff --git a/libcontainer/process_linux.go b/libcontainer/process_linux.go index 889a4b18..6c8ac0f4 100644 --- a/libcontainer/process_linux.go +++ b/libcontainer/process_linux.go @@ -340,7 +340,7 @@ loop: } } if !sentRun { - return newSystemError(fmt.Errorf("could not synchronise with container process")) + return newSystemError(fmt.Errorf("could not synchronise with container process: %v", ierr)) } if p.config.Config.Namespaces.Contains(configs.NEWNS) && !sentResume { return newSystemError(fmt.Errorf("could not synchronise after executing prestart hooks with container process"))