-
Notifications
You must be signed in to change notification settings - Fork 48
Conversation
Override the default golang panic handling by printing a full traceback (not just for the current goroutine) and dumping core to allow crash-handling programs to log the details. Fixes kata-containers#57. Signed-off-by: James O. D. Hunt <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -60,6 +61,11 @@ func initLogger(logLevel string) error { | |||
return nil | |||
} | |||
|
|||
func init() { | |||
// Force coredump + full stacktrace on internal error | |||
debug.SetTraceback("crash") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it show up through stderr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. afaics, when an internal error occurs, the go runtime calls builtin.print()
, which does indeed write to stderr:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jodh-intel I assume that if we set a logger with logrus, those traces will go to this defined logger right ?
Otherwise we'll get the error printed on stderr of our console, instead of the journal, which is not the expected behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe so. This is a golang facility which doesn't provide us with a lot of control. The ideal would obviously be to log the error but as this is an unrecoverable failure scenario, the best we can do (easily) I think is squirt the data back to the user. We could start playing games like modifying the value of Stderr
I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I get it. Then this is fine for now, but we could investigate how to make this being redirected through the logrus logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we override stderr
with a real local file or something like syslogd in such case? Sending backtrace to user's stderr might leak security bugs. If not, IMO we should make the dump configurable and do not enable it in a production environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI failing due to clearcontainers/runtime#1044. |
Override the default golang panic handling by printing a full traceback
(not just for the current goroutine) and dumping core to allow
crash-handling programs to log the details.
Fixes #57.
Signed-off-by: James O. D. Hunt [email protected]