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

Completion of non-existent file make zsh segfault #343

Closed
pbosab opened this issue Sep 23, 2021 · 10 comments
Closed

Completion of non-existent file make zsh segfault #343

pbosab opened this issue Sep 23, 2021 · 10 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@pbosab
Copy link

pbosab commented Sep 23, 2021

  • zsh-autocomplete version: latest git
  • Zsh version: /usr/bin/zsh zsh-5.8-0-g77d203f
  • Framework: none
  • Plugin manager: none
  • Operating system: linux-gnu

made a new .zshrc empty, with only:

source /usr/share/zsh/plugins/zsh-autocomplete/zsh-autocomplete.plugin.zsh
zstyle ':autocomplete:*' min-delay 5.0
zstyle ':autocomplete:*' widget-style menu-select

(5.0 was only for testing purpose)

now try to "cat /var/log/the_first_letter_of_a_non_existent_file" and TAB before the 5sec
in my example:

cat /var/log/xTAB

zsh segfault:

zsh[18453]: segfault at 555eba49b15d ip 00007f404af7c3c0 sp 00007fff26cef420 error 4 in complist.so[7f404af76000+a000]
Code: 00 e8 54 a5 ff ff 48 8b 3d 45 6f 00 00 ff 15 27 67 00 00 4c 8b 35 48 6a 00 00 c7 05 1a 71 00 00 01 00 00 00 eb 2d 0f 1f 40 00 <8b> 47 60 89 c2 81 e2 00 40 00 00 75 14 a9 20 08 00 00 74 7f 48 8b
@pbosab pbosab added the bug Something isn't working label Sep 23, 2021
@marlonrichert
Copy link
Owner

Sorry, but I'm unable to reproduce this.

In your test .zshrc, can you add the following, then try again and paste me the lines that occur before the segfault?

functions -t .autocomplete.complete-word.completion-widget

@marlonrichert marlonrichert added question Further information is requested and removed bug Something isn't working labels Sep 24, 2021
@pbosab
Copy link
Author

pbosab commented Sep 24, 2021

here you go:
tmux-0-0-0-20210924T145201.log

@marlonrichert
Copy link
Owner

Thanks! It looks like the crash happens after the widget's completion function has returned.

Can you try adding the following to your test .zshrc before sourcing zsh-autocomplete?

zstyle ':autocomplete:*' async off

Does the crash still occur then?

If it doesn't, then try the following:

  1. Remove the statement above from the .zshrc.
  2. Restart the test shell.
  3. Run functions -t .autocomplete.async.list-choices.completion-widget.
  4. Reproduce the crash.
  5. Send me the file that $_autocomplete__log_file points to.

@pbosab
Copy link
Author

pbosab commented Sep 24, 2021

Thanks! It looks like the crash happens after the widget's completion function has returned.

Can you try adding the following to your test .zshrc before sourcing zsh-autocomplete?

zstyle ':autocomplete:*' async off

Does the crash still occur then?

it doesn't

If it doesn't, then try the following:

1. Remove the statement above from the `.zshrc`.

2. Restart the test shell.

3. Run `functions -t .autocomplete.async.list-choices.completion-widget`.

4. Reproduce the crash.

5. Send me the file that `$_autocomplete__log_file` points to.

only these lines:


# 3. .autocomplete.async.list-choices.completion-widget [22:20:11.235]
397 ->1	unset _autocomplete__mesg _autocomplete__comp_mesg _autocomplete__words _autocomplete__current
399	if [[ ! -v 1 || 0.9927980000 != <->.<-> || ! -v 2 || 0 != <-> ]]
404	.autocomplete.async.insufficient-input

# 4. .autocomplete.async.insufficient-input [22:20:11.235]
377	local min_input=''
378	zstyle -s :autocomplete:list-choices min-input min_input
380	local ignored=''
381	zstyle -s :autocomplete:list-choices ignored-input ignored
382 ->1	if ((  1 == 1 && 0 < min_input  ))
384	then compstate[list]='' 
385	then true

# 3. .autocomplete.async.list-choices.completion-widget [22:20:11.236]
405	cmdand return

@marlonrichert
Copy link
Owner

Thanks. Can you try this?

  1. Start the test shell.
  2. Run
    functions -t \
       .autocomplete.async.complete.fd-widget.inner \
       .autocomplete.async.list-choices.completion-widget
  3. Reproduce the crash, noting the exact time when it occurred.
  4. Send me the time of the crash and the file that $_autocomplete__log_file points to.

@pbosab
Copy link
Author

pbosab commented Sep 25, 2021

Thanks. Can you try this?

1. Start the test shell.

2. Run
   ```shell
   functions -t \
      .autocomplete.async.complete.fd-widget.inner \
      .autocomplete.async.list-choices.completion-widget
   ```

3. Reproduce the crash, noting the exact time when it occurred.

mh, don't know how to do this, since it happens when i tab and the terminal close.
if you can tell me how to do this, i can try.

4. Send me the time of the crash and the file that `$_autocomplete__log_file` points to.

here is the file:
2021-09-26.log

thanks

@marlonrichert
Copy link
Owner

mh, don't know how to do this, since it happens when i tab and the terminal close. if you can tell me how to do this, i can try.

Have another terminal window open where you execute

print -P — '%D{%T.%.}'

roughly at the same time as the crash.

It would also help if you wait a couple of seconds before pressing the Tab that causes the crash.

These two things combined will help me identify the exact spot in the log where things go wrong.

@pbosab
Copy link
Author

pbosab commented Sep 26, 2021

2021-09-26.log

-13:08:22.571

hope it helps

@marlonrichert marlonrichert self-assigned this Sep 26, 2021
@marlonrichert
Copy link
Owner

marlonrichert commented Sep 27, 2021

Thanks, I'm able to reproduce it now. It looks like a bug in zsh. I will try to narrow it down to a simpler test case, so I can report it.

@marlonrichert marlonrichert added bug Something isn't working and removed question Further information is requested labels Sep 27, 2021
@marlonrichert marlonrichert changed the title autocomplete of non-existent file make zsh segfault Completion of non-existent file make zsh segfault Sep 27, 2021
@marlonrichert marlonrichert added the help wanted Extra attention is needed label Oct 3, 2021
@marlonrichert
Copy link
Owner

@pbosab It's fixed now. PS: If you enjoy using my software, please consider sponsoring me. 🙂

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants