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

Panic when killing script since 83b6033 'main.go' #3863

Closed
5 of 10 tasks
LangLangBart opened this issue Jun 14, 2024 · 1 comment
Closed
5 of 10 tasks

Panic when killing script since 83b6033 'main.go' #3863

LangLangBart opened this issue Jun 14, 2024 · 1 comment
Labels

Comments

@LangLangBart
Copy link
Contributor

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.53.0 (brew)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

Since commit 83b6033 (main.go), I noticed a panic when killing a script, where fzf runs.

--- a/main.go
+++ b/main.go
@@ -36,5 +36,5 @@ func printScript(label string, content []byte) {
 
 func exit(code int, err error) {
- if err != nil {
+ if code == fzf.ExitError {
    fmt.Fprintln(os.Stderr, err.Error())
  }

to reproduce

Run this small script in a terminal tab; the $$ is copied to your clipboard (macOS only).

#!/usr/bin/env bash

echo $$ | pbcopy
: | FZF_DEFAULT_OPTS="" fzf

In a second terminal tab, run the following:

kill -15 <copied_pid>

Examine the first terminal tab and notice the panic.

panic: runtime error: invalid memory address or nil pointer dereference                                                            
                                                                       [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xb286143]

            goroutine 1 [running]:
                                  main.exit(0x2, {0x0?, 0x0?})
                                                                github.com/junegunn/fzf/main.go:39 +0x23
                                                                                                        main.main()
                                                                                                                        github.com/junegunn/fzf/main.go:81 +0x198

possible solution

Maybe check for nil or have a dedicated message for nil?

if code == fzf.ExitError && err != nil
@junegunn
Copy link
Owner

Thanks, nice find.

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

No branches or pull requests

2 participants