aandrew-me / tgpt

AI Chatbots in terminal without needing API keys
GNU General Public License v3.0
2.04k stars 171 forks source link

`tgpt` crashes with "invalid memory address or nil pointer dereference" when using `-w` flag #301

Closed nazdridoy closed 1 month ago

nazdridoy commented 1 month ago

When running the tgpt command with the -w or --whole flag, the program crashes with a runtime error indicating an "invalid memory address or nil pointer dereference." This issue seems to occur in the getWholeText function.

Steps to Reproduce:

  1. Run the command: tgpt -w "hello"
  2. Observe the crash with the following error message:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6357f45319d4]

goroutine 1 [running]:
main.getWholeText({0xc000030b70, 0x2a})
    /build/tgpt/src/tgpt-2.8.1/helper.go:290 +0x194
main.main()
    /build/tgpt/src/tgpt-2.8.1/main.go:171 +0x1858

Potential Cause:

The error seems to originate from the getWholeText function in helper.go and is called from the main function in main.go. It is possible that one of the pointers or variables used in these functions is not properly initialized.

Expected Behavior:

The command should execute without crashing and return the expected output.

Environment:

aandrew-me commented 1 month ago

Thanks for informing