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

Micro crashes with a custom keybind that executes 2 terminal commands #2931

Open
redsti-github opened this issue Sep 20, 2023 · 5 comments
Open

Comments

@redsti-github
Copy link

Description of the problem or steps to reproduce

add a keybind that looks like this (any keybind that runs 2 command:term ... commands should work):

   "Ctrl-w": "command:term echo a,command:term echo b"

When you run the keybind (in this case, pressing Ctrl-w), micro crashes with the following output:

Micro encountered an error: runtime.errorString runtime error: invalid memory address or nil pointer dereference
runtime/panic.go:260 (0x557f42eaa8d6)
runtime/panic.go:259 (0x557f42eaa8a6)
github.com/zyedidia/micro/internal/action/bufpane.go:146 (0x557f433081f8)
github.com/zyedidia/micro/internal/action/bufpane.go:31 (0x557f43308036)
github.com/zyedidia/micro/internal/action/bufpane.go:449 (0x557f43309459)
github.com/zyedidia/micro/internal/action/bufpane.go:365 (0x557f43308f7c)
github.com/zyedidia/micro/internal/action/tab.go:254 (0x557f43318f18)
github.com/zyedidia/micro/internal/action/tab.go:136 (0x557f4331885c)
github.com/zyedidia/micro/cmd/micro/micro.go:445 (0x557f4333e1a7)
github.com/zyedidia/micro/cmd/micro/micro.go:382 (0x557f4333dc12)
runtime/proc.go:250 (0x557f42e97353)
runtime/asm_amd64.s:1594 (0x557f42ec5e41)
 
If you can reproduce this error, please report it at https://github.com/zyedidia/micro/issues

Specifications

Commit hash: 2.0.11
OS: Debian 12
Terminal: bash

@JoeKar
Copy link
Collaborator

JoeKar commented Sep 25, 2023

That's a tricky one, since the actual command, term and pane constellation isn't designed to handle two term commands at the same time so far. But even then it shouldn't crash:

The actual buffer splits the commands correctly and performs the first by creating and activating a new tab (TermPane) and invoking the user command. While this TermPane is still the active pane the previous buffer pulls the actual pane, which isn't of type BufPane any longer and thus receives nil. Afterwards a simple nil access is performed by invoking the second command.

Solving this isn't that simple any longer...at least from my current knowledge about the involved function chains.

We could prevent the crash by checking for chained term commands, but this will involve additional checks to validate the user input and trying to workaround the real root cause. I wouldn't prefer that...
I currently suggest introduction a pane abstraction, from which every other pane (buf, info, term & raw) derives. Afterwards the execAction can be performed at the right one. Since the TermPane should be allowed to perform term commands as well as the BufPane.

@zyedidia
Any thoughts about that?

@bobhwasatch
Copy link

bobhwasatch commented Sep 28, 2023

I have a very similar crash with just running the term command normally (ctrl-e, term right after starting micro). My case gets a SIGSEGV and wrecks my terminal (takes several 'reset' commands to make it work again).

Can't cut-and-paste the error because of the terminal issue but it starts out:

termpanic: runtime error: invalid memory address or null pointer dereference
[signal SIGSEGV ...]
goroutine 9 [running]: bytes.(*Buffer).ReadFrom(0x0, {0xb16ee0, 0xc000096cf8})

OS is Debian 12 and I am using the static build:

Version: 2.0.12
Commit hash: c2cebaa
Compiled on September 06, 2023

@bobhwasatch
Copy link

My issue my have already been fixed. I just compiled from master and the issue is gone.

$ git clone https://github.com/zyedidia/micro.git
$ make

Version: 2.0.13-dev.8
Commit hash: 1231d24
Compiled on September 28, 2023

@JoeKar
Copy link
Collaborator

JoeKar commented Oct 1, 2023

My issue my have already been fixed. I just compiled from master and the issue is gone.

I don't think so, because I reproduced it with the latest HEAD at the master and my code analysis was based on that too.

@bobhwasatch
Copy link

bobhwasatch commented Oct 1, 2023

Just to be clear, my issue was crashing just from running "term" once. Sorry for the confusion.

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

No branches or pull requests

3 participants