Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

funcr: handle fmt.Stringer that panics on nil #125

Closed
pohly opened this issue Dec 17, 2021 · 0 comments · Fixed by #130
Closed

funcr: handle fmt.Stringer that panics on nil #125

pohly opened this issue Dec 17, 2021 · 0 comments · Fixed by #130

Comments

@pohly
Copy link
Contributor

pohly commented Dec 17, 2021

I ran into this with klog in Kubernetes (see kubernetes/klog#278). While I haven't tested it, funcr is probably also affected, at least here but potentially also elsewhere:

value = v.String()

The problem is that log calls might pass a nil pointer for a struct which implements fmt.Stringer, but then segfaults when called. Here's an example:
https://github.com/kubernetes/kubernetes/blob/a1e8a5bf39d48719dfbcf49ea09223ee04840502/pkg/kubelet/kubelet.go#L2334-L2335

I think it is reasonable to expect that a logging implementation is resilient against such problems. That means that funcr must either check for nil beforehand or deal with the panic. I'm undecided. Perhaps fmt.Sprintf("%q", <nil stringer>) can serve as reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant