Christian wrote:
> On Sa, 08 Mai 2021, Christian Brabandt wrote:
>
> > Trying to convert vim-airline to vim9 script, I see the following crash:
> >
> > I see the following error before Vim crashes and most likely there is a
> > problem with my newly created vim9 script, but I don't think Vim should
> > crash then. I guess the error makes the instruction pointer null.
> >
>
> I think the crash was caused by this function:
>
> ,----
> | def airline#highlighter#exec(group: string, clrs: list<any>): void
> | [...]
> | if old_hi != new_hi || !s:hl_group_exists(group)
> | var cmd = ''
> | cmd = printf('hi %s%s', group, s:GetHiCmd(colors))
> | try
> | :exe cmd
> | catch /^Vim\%((\a\+)\)\=:E421:/
> | group=matchstr(v:exception, '\w\+\ze=')
> | var color=matchstr(v:exception, '=\zs\w\+')
> | let cmd=substitute(cmd, color, 'grey', 'g')
> | exe cmd
> | airline#util#warning('color definition for group ' .. group .. ' not
> found, using grey as fallback')
> | catch
> | airline#util#warning('Error when running command: '. cmd)
> | endtry
> | [...]
> | endif
> | enddef
> `----
>
> I think the crucial part is the catch section, trying to parse
> v:exception and trying to reuse the function argument name group.
Is that really using a single dot for string concatenation? That should
fail during compilation. Oh, there also is a :let there, so this can't
possibly be compiled. Maybe the problem is at the caller of this
function, when compilation produces an error?
> I have that part now rewritten as this:
>
> ,----
> | catch /^Vim\%((\a\+)\)\=:E421:/
> | var grp = matchstr(v:exception, '\w\+\ze=')
> | var clr = matchstr(v:exception, '=\zs\w\+')
> | cmd = substitute(cmd, clr, 'grey', 'g')
> | :exe cmd
> `----
>
> and at least it is not crashing anymore.
I cannot guess why the instruction is NULL. Easiest would be to run Vim
in gdb and it should stop when it happens. Then you can look around,
such as the value of "ectx->ec_iidx".
You can also use ch_log() to write some events to a log file (started
with ch_logfile()) in case it's timing sensitive.
And you could disassemble that function:
:disass airline#highlighter#exec
I hope you can find a reproduction case, so we can have a test for this
failure.
--
Hear about the guy who played a blank tape at full blast?
The mime next door went nuts.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202105081235.148CZrPW1627118%40masaka.moolenaar.net.