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.
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!".