~emersion/soju-dev

fix panic stacktrace print formatting v1 APPLIED

Jeff Martin: 1
 fix panic stacktrace print formatting

 1 files changed, 2 insertions(+), 2 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/soju-dev/patches/34520/mbox | git am -3
Learn more about email & git

[PATCH] fix panic stacktrace print formatting Export this patch

This change uses string formatting for the output of debug.Stack. The
output of debug.Stack is []byte, which isn't human readable.

Also use the '%s' verb instead of '%v' for the stacktrace, since we know
what type it is.
---
 server.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server.go b/server.go
index 48cfc7c..e2b502a 100644
--- a/server.go
+++ b/server.go
@@ -393,7 +393,7 @@ func (s *Server) addUserLocked(user *database.User) *user {
	go func() {
		defer func() {
			if err := recover(); err != nil {
				s.Logger.Printf("panic serving user %q: %v\n%v", user.Username, err, string(debug.Stack()))
				s.Logger.Printf("panic serving user %q: %v\n%s", user.Username, err, string(debug.Stack()))
			}

			s.lock.Lock()
@@ -414,7 +414,7 @@ var lastDownstreamID uint64
func (s *Server) handle(ic ircConn) {
	defer func() {
		if err := recover(); err != nil {
			s.Logger.Printf("panic serving downstream %q: %v\n%v", ic.RemoteAddr(), err, debug.Stack())
			s.Logger.Printf("panic serving downstream %q: %v\n%s", ic.RemoteAddr(), err, string(debug.Stack()))
		}
	}()

-- 
2.34.1
Thanks, pushed with a minor edit.

On Sunday, August 7th, 2022 at 22:38, Jeff Martin <jeffmartin@gmail.com> wrote: