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

Data race #67

Closed
VladyslavLukyanenko opened this issue Jul 28, 2023 · 5 comments · Fixed by #68 · May be fixed by muesli/termenv#146
Closed

Data race #67

VladyslavLukyanenko opened this issue Jul 28, 2023 · 5 comments · Fixed by #68 · May be fixed by muesli/termenv#146

Comments

@VladyslavLukyanenko
Copy link

==================
WARNING: DATA RACE
Write at 0x00c00020e800 by goroutine 18:
  runtime.slicecopy()
      /opt/homebrew/opt/go/libexec/src/runtime/slice.go:310 +0x0
  bytes.(*Buffer).WriteString()
      /opt/homebrew/opt/go/libexec/src/bytes/buffer.go:184 +0x108
  github.com/charmbracelet/log.(*Logger).textFormatter()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/text.go:152 +0x26c
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:107 +0xc9c
  github.com/charmbracelet/log.(*Logger).Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:310 +0x434
  github.com/charmbracelet/log.(*stdLogWriter).Write()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/stdlog.go:41 +0x384
  log.(*Logger).Output()
      /opt/homebrew/opt/go/libexec/src/log/log.go:194 +0x344
  log.(*Logger).Printf()
      /opt/homebrew/opt/go/libexec/src/log/log.go:204 +0x84
  github.com/charmbracelet/wish/logging.MiddlewareWithLogger.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logging/logging.go:47 +0x4c0
  github.com/charmbracelet/wish/activeterm.Middleware.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/activeterm/activeterm.go:21 +0x54
  github.com/charmbracelet/ssh.(*session).handleRequests.func1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:259 +0x4c

Previous read at 0x00c00020e800 by main goroutine:
  runtime.racereadrange()
      <autogenerated>:1 +0x14
  internal/poll.ignoringEINTRIO()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:794 +0x39c
  internal/poll.(*FD).Write()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:383 +0x1ec
  os.(*File).write()
      /opt/homebrew/opt/go/libexec/src/os/file_posix.go:48 +0x90
  os.(*File).Write()
      /opt/homebrew/opt/go/libexec/src/os/file.go:175 +0x70
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:110 +0xd48
  github.com/charmbracelet/log.Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/pkg.go:157 +0xc8c
  github.com/charmbracelet/wishlist.Serve()
      /Users/vlad/TestArea/wishlist/server.go:93 +0xc50
  main.glob..func4()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:189 +0x584
  github.com/spf13/cobra.(*Command).execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x7cc
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x48c
  github.com/spf13/cobra.(*Command).Execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:992 +0x158
  main.main()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:230 +0x140

Goroutine 18 (running) created at:
  github.com/charmbracelet/ssh.(*session).handleRequests()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:258 +0x62c
  github.com/charmbracelet/ssh.DefaultSessionHandler()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:106 +0x2d8
  github.com/charmbracelet/ssh.(*Server).HandleConn.func4()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/server.go:305 +0x84
==================
==================
WARNING: DATA RACE
Write at 0x00c00020e813 by goroutine 18:
  bytes.(*Buffer).WriteByte()
      /opt/homebrew/opt/go/libexec/src/bytes/buffer.go:282 +0xe0
  github.com/charmbracelet/log.(*Logger).textFormatter()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/text.go:153 +0x278
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:107 +0xc9c
  github.com/charmbracelet/log.(*Logger).Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:310 +0x434
  github.com/charmbracelet/log.(*stdLogWriter).Write()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/stdlog.go:41 +0x384
  log.(*Logger).Output()
      /opt/homebrew/opt/go/libexec/src/log/log.go:194 +0x344
  log.(*Logger).Printf()
      /opt/homebrew/opt/go/libexec/src/log/log.go:204 +0x84
  github.com/charmbracelet/wish/logging.MiddlewareWithLogger.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logging/logging.go:47 +0x4c0
  github.com/charmbracelet/wish/activeterm.Middleware.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/activeterm/activeterm.go:21 +0x54
  github.com/charmbracelet/ssh.(*session).handleRequests.func1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:259 +0x4c

Previous read at 0x00c00020e810 by main goroutine:
  runtime.racereadrange()
      <autogenerated>:1 +0x14
  internal/poll.ignoringEINTRIO()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:794 +0x39c
  internal/poll.(*FD).Write()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:383 +0x1ec
  os.(*File).write()
      /opt/homebrew/opt/go/libexec/src/os/file_posix.go:48 +0x90
  os.(*File).Write()
      /opt/homebrew/opt/go/libexec/src/os/file.go:175 +0x70
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:110 +0xd48
  github.com/charmbracelet/log.Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/pkg.go:157 +0xc8c
  github.com/charmbracelet/wishlist.Serve()
      /Users/vlad/TestArea/wishlist/server.go:93 +0xc50
  main.glob..func4()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:189 +0x584
  github.com/spf13/cobra.(*Command).execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x7cc
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x48c
  github.com/spf13/cobra.(*Command).Execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:992 +0x158
  main.main()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:230 +0x140

Goroutine 18 (running) created at:
  github.com/charmbracelet/ssh.(*session).handleRequests()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:258 +0x62c
  github.com/charmbracelet/ssh.DefaultSessionHandler()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:106 +0x2d8
  github.com/charmbracelet/ssh.(*Server).HandleConn.func4()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/server.go:305 +0x84
==================
==================
WARNING: DATA RACE
Write at 0x00c00020e828 by goroutine 18:
  bytes.(*Buffer).WriteByte()
      /opt/homebrew/opt/go/libexec/src/bytes/buffer.go:282 +0xe0
  github.com/charmbracelet/log.(*Logger).textFormatter()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/text.go:159 +0x500
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:107 +0xc9c
  github.com/charmbracelet/log.(*Logger).Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:310 +0x434
  github.com/charmbracelet/log.(*stdLogWriter).Write()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/stdlog.go:41 +0x384
  log.(*Logger).Output()
      /opt/homebrew/opt/go/libexec/src/log/log.go:194 +0x344
  log.(*Logger).Printf()
      /opt/homebrew/opt/go/libexec/src/log/log.go:204 +0x84
  github.com/charmbracelet/wish/logging.MiddlewareWithLogger.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logging/logging.go:47 +0x4c0
  github.com/charmbracelet/wish/activeterm.Middleware.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/activeterm/activeterm.go:21 +0x54
  github.com/charmbracelet/ssh.(*session).handleRequests.func1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:259 +0x4c

Previous read at 0x00c00020e828 by main goroutine:
  runtime.racereadrange()
      <autogenerated>:1 +0x14
  internal/poll.ignoringEINTRIO()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:794 +0x39c
  internal/poll.(*FD).Write()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:383 +0x1ec
  os.(*File).write()
      /opt/homebrew/opt/go/libexec/src/os/file_posix.go:48 +0x90
  os.(*File).Write()
      /opt/homebrew/opt/go/libexec/src/os/file.go:175 +0x70
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:110 +0xd48
  github.com/charmbracelet/log.Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/pkg.go:157 +0xc8c
  github.com/charmbracelet/wishlist.Serve()
      /Users/vlad/TestArea/wishlist/server.go:93 +0xc50
  main.glob..func4()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:189 +0x584
  github.com/spf13/cobra.(*Command).execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x7cc
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x48c
  github.com/spf13/cobra.(*Command).Execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:992 +0x158
  main.main()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:230 +0x140

Goroutine 18 (running) created at:
  github.com/charmbracelet/ssh.(*session).handleRequests()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:258 +0x62c
  github.com/charmbracelet/ssh.DefaultSessionHandler()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:106 +0x2d8
  github.com/charmbracelet/ssh.(*Server).HandleConn.func4()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/server.go:305 +0x84
==================

This data race happens upon shutting down wishlist server.

@aymanbagabas
Copy link
Member

Hi @VladyslavLukyanenko, thanks for reporting the bug. Could you provide a minimum reproducible code?

@VladyslavLukyanenko
Copy link
Author

VladyslavLukyanenko commented Jul 28, 2023

Hi @VladyslavLukyanenko, thanks for reporting the bug. Could you provide a minimum reproducible code?

Clone wishlist, run it using go run -race . serve there's a lot of race conditions but this one happens upon shutting the server down/exiting it

@VladyslavLukyanenko
Copy link
Author

Note: you need to connect to the server and then it happens, launching it and closing it won't trigger it

@aymanbagabas
Copy link
Member

Could you test this with these branches muesli/termenv#146 charmbracelet/lipgloss#210?

@VladyslavLukyanenko
Copy link
Author

so the other data races are completely gone, thanks for that, but this one still persists.

==================
WARNING: DATA RACE
Write at 0x00c0002fc200 by goroutine 18:
  runtime.slicecopy()
      /opt/homebrew/opt/go/libexec/src/runtime/slice.go:310 +0x0
  bytes.(*Buffer).WriteString()
      /opt/homebrew/opt/go/libexec/src/bytes/buffer.go:184 +0x108
  github.com/charmbracelet/log.(*Logger).textFormatter()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/text.go:152 +0x26c
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:107 +0xc9c
  github.com/charmbracelet/log.(*Logger).Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:310 +0x434
  github.com/charmbracelet/log.(*stdLogWriter).Write()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/stdlog.go:41 +0x384
  log.(*Logger).Output()
      /opt/homebrew/opt/go/libexec/src/log/log.go:194 +0x344
  log.(*Logger).Printf()
      /opt/homebrew/opt/go/libexec/src/log/log.go:204 +0x84
  github.com/charmbracelet/wish/logging.MiddlewareWithLogger.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logging/logging.go:47 +0x4c0
  github.com/charmbracelet/wish/activeterm.Middleware.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/activeterm/activeterm.go:21 +0x54
  github.com/charmbracelet/ssh.(*session).handleRequests.func1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:259 +0x4c

Previous read at 0x00c0002fc200 by main goroutine:
  runtime.racereadrange()
      <autogenerated>:1 +0x14
  internal/poll.ignoringEINTRIO()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:794 +0x39c
  internal/poll.(*FD).Write()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:383 +0x1ec
  os.(*File).write()
      /opt/homebrew/opt/go/libexec/src/os/file_posix.go:48 +0x90
  os.(*File).Write()
      /opt/homebrew/opt/go/libexec/src/os/file.go:175 +0x70
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:110 +0xd48
  github.com/charmbracelet/log.Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/pkg.go:157 +0xc8c
  github.com/charmbracelet/wishlist.Serve()
      /Users/vlad/TestArea/wishlist/server.go:93 +0xc50
  main.glob..func4()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:189 +0x584
  github.com/spf13/cobra.(*Command).execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x7cc
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x48c
  github.com/spf13/cobra.(*Command).Execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:992 +0x158
  main.main()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:230 +0x140

Goroutine 18 (running) created at:
  github.com/charmbracelet/ssh.(*session).handleRequests()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:258 +0x62c
  github.com/charmbracelet/ssh.DefaultSessionHandler()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:106 +0x2d8
  github.com/charmbracelet/ssh.(*Server).HandleConn.func4()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/server.go:305 +0x84
==================
==================
WARNING: DATA RACE
Write at 0x00c0002fc213 by goroutine 18:
  bytes.(*Buffer).WriteByte()
      /opt/homebrew/opt/go/libexec/src/bytes/buffer.go:282 +0xe0
  github.com/charmbracelet/log.(*Logger).textFormatter()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/text.go:153 +0x278
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:107 +0xc9c
  github.com/charmbracelet/log.(*Logger).Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:310 +0x434
  github.com/charmbracelet/log.(*stdLogWriter).Write()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/stdlog.go:41 +0x384
  log.(*Logger).Output()
      /opt/homebrew/opt/go/libexec/src/log/log.go:194 +0x344
  log.(*Logger).Printf()
      /opt/homebrew/opt/go/libexec/src/log/log.go:204 +0x84
  github.com/charmbracelet/wish/logging.MiddlewareWithLogger.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logging/logging.go:47 +0x4c0
  github.com/charmbracelet/wish/activeterm.Middleware.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/activeterm/activeterm.go:21 +0x54
  github.com/charmbracelet/ssh.(*session).handleRequests.func1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:259 +0x4c

Previous read at 0x00c0002fc210 by main goroutine:
  runtime.racereadrange()
      <autogenerated>:1 +0x14
  internal/poll.ignoringEINTRIO()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:794 +0x39c
  internal/poll.(*FD).Write()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:383 +0x1ec
  os.(*File).write()
      /opt/homebrew/opt/go/libexec/src/os/file_posix.go:48 +0x90
  os.(*File).Write()
      /opt/homebrew/opt/go/libexec/src/os/file.go:175 +0x70
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:110 +0xd48
  github.com/charmbracelet/log.Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/pkg.go:157 +0xc8c
  github.com/charmbracelet/wishlist.Serve()
      /Users/vlad/TestArea/wishlist/server.go:93 +0xc50
  main.glob..func4()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:189 +0x584
  github.com/spf13/cobra.(*Command).execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x7cc
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x48c
  github.com/spf13/cobra.(*Command).Execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:992 +0x158
  main.main()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:230 +0x140

Goroutine 18 (running) created at:
  github.com/charmbracelet/ssh.(*session).handleRequests()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:258 +0x62c
  github.com/charmbracelet/ssh.DefaultSessionHandler()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:106 +0x2d8
  github.com/charmbracelet/ssh.(*Server).HandleConn.func4()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/server.go:305 +0x84
==================
==================
WARNING: DATA RACE
Write at 0x00c0002fc228 by goroutine 18:
  bytes.(*Buffer).WriteByte()
      /opt/homebrew/opt/go/libexec/src/bytes/buffer.go:282 +0xe0
  github.com/charmbracelet/log.(*Logger).textFormatter()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/text.go:159 +0x500
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:107 +0xc9c
  github.com/charmbracelet/log.(*Logger).Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:310 +0x434
  github.com/charmbracelet/log.(*stdLogWriter).Write()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/stdlog.go:41 +0x384
  log.(*Logger).Output()
      /opt/homebrew/opt/go/libexec/src/log/log.go:194 +0x344
  log.(*Logger).Printf()
      /opt/homebrew/opt/go/libexec/src/log/log.go:204 +0x84
  github.com/charmbracelet/wish/logging.MiddlewareWithLogger.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logging/logging.go:47 +0x4c0
  github.com/charmbracelet/wish/activeterm.Middleware.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/activeterm/activeterm.go:21 +0x54
  github.com/charmbracelet/ssh.(*session).handleRequests.func1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:259 +0x4c

Previous read at 0x00c0002fc228 by main goroutine:
  runtime.racereadrange()
      <autogenerated>:1 +0x14
  internal/poll.ignoringEINTRIO()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:794 +0x39c
  internal/poll.(*FD).Write()
      /opt/homebrew/opt/go/libexec/src/internal/poll/fd_unix.go:383 +0x1ec
  os.(*File).write()
      /opt/homebrew/opt/go/libexec/src/os/file_posix.go:48 +0x90
  os.(*File).Write()
      /opt/homebrew/opt/go/libexec/src/os/file.go:175 +0x70
  github.com/charmbracelet/log.(*Logger).log()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/logger.go:110 +0xd48
  github.com/charmbracelet/log.Info()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/pkg.go:157 +0xc8c
  github.com/charmbracelet/wishlist.Serve()
      /Users/vlad/TestArea/wishlist/server.go:93 +0xc50
  main.glob..func4()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:189 +0x584
  github.com/spf13/cobra.(*Command).execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x7cc
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x48c
  github.com/spf13/cobra.(*Command).Execute()
      /Users/vlad/go/pkg/mod/github.com/spf13/[email protected]/command.go:992 +0x158
  main.main()
      /Users/vlad/TestArea/wishlist/cmd/wishlist/main.go:230 +0x140

Goroutine 18 (running) created at:
  github.com/charmbracelet/ssh.(*session).handleRequests()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:258 +0x62c
  github.com/charmbracelet/ssh.DefaultSessionHandler()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/session.go:106 +0x2d8
  github.com/charmbracelet/ssh.(*Server).HandleConn.func4()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/[email protected]/server.go:305 +0x84
==================

aymanbagabas added a commit that referenced this issue Jul 28, 2023
The formatters write to the internal buffer. We need to guard that
before we read the buffer.

Fixes: #67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants