Thanks for thinking about the cause.

> > I wrote:
> >
> > > Patch 9.0.0561
> > > Problem:    When a test gets stuck it just hangs forever.
> > > Solution:   Set a timeout of 30 seconds.
> > > Files:      src/testdir/runtest.vim
> >
> > This is very weird.  After including this patch a cscope test started
> > failing.  The error message is confusing, pointing to line 599 of
> > testdir/runtest.vim, which does not exist.  Running "make test_csope"
> > gets the same error every time.
> >
> > Removing the added line makes the test pass again.  However,
> > commenting-out the lines does not!  Thus it's not the commands that
> > cause the problem, but the added text in the function.  Deleting some
> > text, without changing the number of lines, makes it work OK again.
> > Weird!
> >
> > I tried a few other things, but could not find out much more.  It does
> > seem related to the fork/exec that cscope does to run cscope, which
> > fails because the command name is wrong.  Perhaps something with signal
> > handling?
> >
> > If someone likes a puzzle, please have a look at this.
> 
> I see that if_cscope.c uses SIGALARM and `alarm(unsigned int seconds)`
> function. If might be related to this issue since patch 9.0.0561 sets
> a timeout.

I commented out the use of alarm() but it did not make any difference.

The timer used doesn't use SIGALARM but the elapsed time.  And
commenting out the timer_start() call also doesn't make a difference.

> Speaking of cscope, I recall noticing 2 issues:
> 
> 1) cscope was accessing invalid memory. I created patch
> for it, which was merged in the master branch of cscope
> git repo but there has not been an official release which
> includes it yet. See:
> 
> https://sourceforge.net/p/cscope/cscope/ci/b3ab5461f1a02aa0a07a6f50bc2fa4da057193d1/
> 
> 2) I recall that cscope test failed on macOS M1 (unrelated
> to above fix). I did not really understand this well enough,
> but I could fix it with this patch:
> 
> https://sourceforge.net/u/dominikoeo/cscope/ci/bugfix/failing-vim-cscope-test-on-macOS-Monterey-M1/~/
> 
> But was never merged into the master branch of cscope
> because it was not clear enough why it fixed vim tests
> on macOS M1.

Well, the failing test doesn't actually execute cscope.  It sets
'cscopeprg' to an invalid command.  The for()/exec() then fails.

I double checked again and can reliable reproduce that with these
comments in src/testdir/runtest.vim the problem happens:

  "if has('timers')
  "  " No test should take longer than 30 seconds.  If it takes longer we
  "  " assume we are stuck and need to break out.
  "  let test_timeout_timer = timer_start(30000, 'TestTimeout')
  "endif

And when deleting some text the problem goes away:

  "if has('timers')
  " 
  "
  "  let test_timeout_timer = timer_start(30000, 'TestTimeout')
  "endif

I first thought there was a race condition, but since it reproduces so
reliable I doubt that.  It's more likely some kind of memory corruption.
I haven't been able to spot it with valgrind, possibly because the
fork() confuses it.  Perhaps you can try with asan.

-- 
Two sheep in a meadow.  One says "baaah".  The other says "exactly!".

 /// 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/20220924122815.888BF1C0728%40moolenaar.net.

Raspunde prin e-mail lui