-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
seg fault when trying to open a '.swp' existed file #8506
Comments
// part of core dump. |
not sure if you can reproduce it, (for now i only faced it when worked with 'ctrlp'), or let it be - close it. :-) |
Can you create a longer stack trace? It looks like it happens when the 'virtualedit' option is being set, I wonder how that is triggered. |
|
Can you try with a asan build (address sanitizer)?
If asan finds a memory error, it will output stacks on stderr.
And post the content of |
Thanks. I can see the start is here: #36 0x000055e2476bb6d8 in apply_autocmds (event=event@entry=EVENT_BUFADD, fname=fname@entry=0x0, fname_io=fname_io@entry=0x0, force=force@entry=0, buf=buf@entry=0x55e2484a5d20) When Quit is selected at the prompt a new buffer is opened. The triggered autocommands then eventually lead to the place where the crash happens. Nothing stands out what is different here from normally opening a new buffer. |
// not sure if related, but from asan.log and only such one and build after 'distclean'. |
I installed https://github.com/ctrlpvim/ctrlp.vim At step 3, pressing CTRL-P I get:
But then pressing |
um.. maybe not related to 'ctrlp', but it do crash at my place when trying to reproduce with 'ctrlp'. |
```
charset.c:1232:11: runtime error: member access within null pointer of type 'struct buf_T'
```
// not sure if related, but from asan.log and only such one and build
after 'distclean'.
Thanks, the previous stack trace didn't show the exact location. So it
turns out curwin->w_buffer is NULL. And that is because close_buffer()
is called before calling buflist_new().
In this case we just want to create an empty buffer to use for the
current buffer. Blocking autocommands seems like the best way to avoid
trouble. It's like creating the first empty buffer when Vim starts.
Try this patch:
*** vim-8.2.3092/src/buffer.c 2021-06-27 22:03:28.637707737 +0200
--- buffer.c 2021-07-03 21:15:54.138076249 +0200
***************
*** 1130,1136 ****
--- 1130,1141 ----
close_buffer(curwin, curbuf, DOBUF_UNLOAD, FALSE, FALSE);
if (old_curbuf == NULL || !bufref_valid(old_curbuf)
|| old_curbuf->br_buf == curbuf)
+ {
+ // Block autocommands here because curwin->w_buffer is NULL.
+ block_autocmds();
buf = buflist_new(NULL, NULL, 1L, BLN_CURBUF | BLN_LISTED);
+ unblock_autocmds();
+ }
else
buf = old_curbuf->br_buf;
if (buf != NULL)
…--
hundred-and-one symptoms of being an internet addict:
88. Every single time you press the 'Get mail' button...it does get new mail.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
@brammool though not sure if there would be side effect, but yes, i verified, looks this patch fixed this crash. |
@brammool though not sure if there would be side effect, but yes, i
verified, looks this patch fixed this crash.
Thanks for checking. If autocommands are used to keep track of existing
buffers that might be confused. But avoiding the crash in more
important.
Unfortunately I haven't been able to reproduce the problem in a test.
Thus I'll send out the patch without a test. If you can reproduce it in
a simple way (without a plugin) let me know. I'll also give it another
try.
…--
From "know your smileys":
:----} You lie like Pinocchio
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
|
I did a bit of debugging, and it looks like the situation can only happen when an autocommand wipes out the current buffer. |
Problem: Crash when using "quit" at recovery prompt and autocommands are triggered. Solution: Block autocommands when creating an empty buffer to use as the current buffer. (closes vim/vim#8506) vim/vim@1d97efc
@brammool i looked into a bit more, |
I cannot reproduce a problem with that Vim command, also not using valgrind. When curwin->w_buffer is NULL then no user commands must be executed. |
the repro steps is:
// perhaps au on |
|
and of course it cannot be reproduced after v8.2.3097 since it blocked all au. |
or maybe 'block all' was acceptable, |
Thanks for the hints, now I managed to make the test fail without the patch. |
Problem: Test for crash fix does not fail without the fix. Solution: Adjust the test sequence. (closes #8506)
:-) and thank you too, let my name and editor/tool stick on vim. glad this would be fixed. |
Problem: Crash when using "quit" at recovery prompt and autocommands are triggered. Solution: Block autocommands when creating an empty buffer to use as the current buffer. (closes vim#8506)
Problem: Test for crash fix does not fail without the fix. Solution: Adjust the test sequence. (closes vim#8506)
Problem: Test for crash fix does not fail without the fix. Solution: Adjust the test sequence. (closes vim/vim#8506) vim/vim@3777d6e Cherry-pick CheckUnix from patch 8.2.1432.
Problem: Test for crash fix does not fail without the fix. Solution: Adjust the test sequence. (closes vim/vim#8506) vim/vim@3777d6e Cherry-pick CheckUnix from patch 8.2.1432.
Problem: Test for crash fix does not fail without the fix. Solution: Adjust the test sequence. (closes vim/vim#8506) vim/vim@3777d6e Cherry-pick CheckUnix from patch 8.2.1432.
…20018) Problem: Test for crash fix does not fail without the fix. Solution: Adjust the test sequence. (closes vim/vim#8506) vim/vim@3777d6e Cherry-pick CheckUnix from patch 8.2.1432.
…eovim#20018) Problem: Test for crash fix does not fail without the fix. Solution: Adjust the test sequence. (closes vim/vim#8506) vim/vim@3777d6e Cherry-pick CheckUnix from patch 8.2.1432.
Describe the bug
seg fault when 1 file was opened in a vim, then tried to open same file in another vim, chose 'q' when prompt '.swp' existed.
To Reproduce
Detailed steps to reproduce the behavior:
Expected behavior
no seg fault.
Screenshots
n/a
Environment (please complete the following information):
Additional context
with 'ctrlp'
The text was updated successfully, but these errors were encountered: