neovim/runtime
Justin M. Keyes f6e19e7334
fix(logging): skip recursion, fix crash #18764
Problem:
1. The main log routine does not protect itself against recursion.
   log_lock() doesn't guard against recursion, it would deadlock...
2. 22b52dd462 (#11501) regressed 6f27f5ef91 (#10172), because
   set_init_1..process_spawn tries to log (see backtrace below), but the
   mutex isn't initialized yet. Even if the mutex were valid, we don't
   want early logging to fallback to stderr because that can break
   embedders when stdio is used for RPC.

    frame 1: 0x00000001001d54f4 nvim`open_log_file at log.c:205:7
    frame 2: 0x00000001001d5390 nvim`logmsg(log_level=1, context="UI: ", func_name=0x0000000000000000, line_num=-1, eol=true, fmt="win_viewport") at log.c:150:20
    frame : 0x000000010039aea2 nvim`ui_call_win_viewport(grid=2, win=1000, topline=0, botline=1, curline=0, curcol=0, line_count=1) at ui_events_call.generated.h:321:3
    frame 4: 0x00000001003dfefc nvim`ui_ext_win_viewport(wp=0x0000000101816400) at window.c:939:5
    frame 5: 0x00000001003ec5b4 nvim`win_ui_flush at window.c:7303:7
    frame 6: 0x00000001003a04c0 nvim`ui_flush at ui.c:508:3
    frame 7: 0x00000001002966ba nvim`do_os_system(argv=0x0000600000c0c000, input=0x0000000000000000, len=0, output=0x0000000000000000, nread=0x00007ff7bfefe830, silent=false, forward_output=false) at shell.c:894:3
    frame 8: 0x0000000100295f68 nvim`os_call_shell(cmd="unset nonomatch; vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >/var/folders/gk/3tttv_md06987tlwpyp62jrw0000gn/T/nvimwwvwfD/0 ~foo", opts=kShellOptExpand | kShellOptSilent | kShellOptHideMess, extra_args=0x0000000000000000) at shell.c:663:18
    frame 9: 0x0000000100295845 nvim`call_shell(cmd="unset nonomatch; vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >/var/folders/gk/3tttv_md06987tlwpyp62jrw0000gn/T/nvimwwvwfD/0 ~foo", opts=kShellOptExpand | kShellOptSilent | kShellOptHideMess, extra_shell_arg=0x0000000000000000) at shell.c:712:14
    frame 10: 0x0000000100294c6f nvim`os_expand_wildcards(num_pat=1, pat=0x00007ff7bfefeb20, num_file=0x00007ff7bfefee58, file=0x00007ff7bfefee60, flags=43) at shell.c:328:7
    ...
    frame 23: 0x000000010028ccef nvim`expand_env_esc(srcp=",~foo", dst="~foo", dstlen=4094, esc=false, one=false, prefix=0x0000000000000000) at env.c:673:17
    frame 24: 0x000000010026fdd5 nvim`option_expand(opt_idx=29, val=",~foo") at option.c:1950:3
    frame 25: 0x000000010026f129 nvim`set_init_1(clean_arg=false) at option.c:558:19
    frame 26: 0x00000001001ea25e nvim`early_init(paramp=0x00007ff7bfeff5f0) at main.c:198:3
    frame 27: 0x00000001001ea6bf nvim`main(argc=1, argv=0x00007ff7bfeff848) at main.c:255:3

Solution:
1. Check for recursion, show "internal error" message.
    - FUTURE: when "remote TUI" is merged, can we remove log_lock()?
2. Skip logging if log_init wasn't called yet.
2022-05-30 13:07:33 -07:00
..
autoload fix(health): correct shada file path #18603 2022-05-17 05:43:35 -07:00
colors vim-patch:partial 2d8ed0203aed (#18675) 2022-05-23 23:49:38 +02:00
compiler vim-patch:partial:3f32a5f1601a (#18555) 2022-05-13 15:20:58 +02:00
doc fix(logging): skip recursion, fix crash #18764 2022-05-30 13:07:33 -07:00
ftplugin vim-patch:partial 2d8ed0203aed (#18675) 2022-05-23 23:49:38 +02:00
indent vim-patch:partial 2d8ed0203aed (#18675) 2022-05-23 23:49:38 +02:00
keymap
lua fix(treesitter): offset directive associates range with capture (#18276) 2022-05-28 19:22:18 +02:00
macros
pack/dist/opt vim-patch:8.2.5010: the terminal debugger uses various global variables 2022-05-26 07:47:00 +08:00
plugin
print
queries/c
spell feat(runtime): import cleanadd.vim from Vim (#17699) 2022-03-13 04:52:45 +00:00
syntax feat(man.vim): list command flags in "gO" outline #17558 2022-05-16 04:49:44 -07:00
tools vim-patch:6304be625ce4 (#16450) 2021-11-27 19:39:42 +01:00
tutor docs(tutor): modify for Neovim rather than Vim (#17092) 2022-01-30 13:53:01 +01:00
bugreport.vim
CMakeLists.txt vim-patch:8.2.3676: unused runtime file (#16441) 2021-11-26 17:16:11 +01:00
delmenu.vim
filetype.lua chore: format runtime with stylua 2022-05-09 16:31:55 +02:00
filetype.vim vim-patch:8.2.5015: Hoon and Moonscript files are not recognized (#18747) 2022-05-25 18:07:58 -06:00
ftoff.vim
ftplugin.vim
ftplugof.vim
indent.vim
indoff.vim
macmap.vim
makemenu.vim
menu.vim vim-patch:partial 1588bc8ebee2 (#17656) 2022-03-09 08:40:16 +01:00
mswin.vim
nvim.appdata.xml NVIM 0.7 2022-04-15 13:38:44 +02:00
nvim.desktop build(nvim.desktop): central Kurdish translation #17065 2022-05-13 11:58:22 -07:00
nvim.png
optwin.vim refactor!: delete insertmode (#18547) 2022-05-22 21:20:18 -06:00
scripts.vim vim-patch:8.2.4095: sed script not recognized by the first line (#17101) 2022-01-15 14:47:25 +01:00
synmenu.vim