[vim/vim] MinGW: tests hang when Vim is built with coverage enabled (PR #20991)

h_east (Vim Github Repository) <[email protected]> Sun, 09 Aug 2026 21:07:05 -0700
Newsgroups gmane.editors.vim.devel
Message-ID <vim/vim/pull/[email protected]>
```
Problem:  When building with MinGW and COVERAGE=yes the tests hang: a
          command started from Vim never returns, although the child
          process has already exited.
Solution: Do not build vimrun.exe with coverage instrumentation.
```

fixes: #20976

---

Found it, and it is not what any of us assumed. Reproduced locally.

`vimrun.exe` is built with `--coverage`, and a gcov-instrumented `vimrun` never
returns from `_wsystem()` even after the child has exited.

## Why only those two jobs

`Make_cyg_ming.mak` builds vimrun with the same `CFLAGS` as Vim itself:

```make
vimrun.exe: vimrun.c
	$(CC) $(CFLAGS) -o vimrun.exe vimrun.c $(LIB)
```

With `COVERAGE=yes` that pulls in `--coverage`. The two failing jobs are the
only ones in the matrix carrying `coverage: yes`. Everything else lines up with
that: MSVC jobs pass, mingw jobs without coverage pass, and NORMAL/TINY pass.

## What is actually happening

When the run is hung, the process tree is:

    gvim (runtest.vim test_assert.vim)
      +- vimrun -s cmd.exe /c (..\gvim ... -S Xafter.vim )
           +- conhost.exe

No child gvim, no cmd.exe - both have already exited. `Xerrors` is on disk and
contains exactly `Expected 0 but got 1`, with no script location prefixed, so
`Test_assert_equal_typed()` did its job correctly and the child quit normally.
The vimrun console shows only the command line it echoes on startup, so it has
not reached `shell returned %d` either. It is stuck inside `_wsystem()`.

So the test, `feedkeys(..., 't')`, the typed-ahead `:qa!` and the child gvim are
all fine. Only the instrumented vimrun is stuck.

## Fix

vimrun is a helper, not part of Vim, and there is no reason to instrument it:

```make
vimrun.exe: vimrun.c
	$(CC) $(filter-out --coverage,$(CFLAGS)) -o vimrun.exe vimrun.c $(LIB)
```

I rebuilt vimrun without `--coverage` locally, changing nothing else, and the
test returns immediately.

## Reproducing

MSVC will never show this. You need mingw and, above all, `COVERAGE=yes`:

    # MSYS2 MINGW32
    mingw32-make -f Make_ming.mak -j2 FEATURES=HUGE GUI=yes IME=yes ICONV=yes \
      VIMDLL=yes STATIC_STDCPLUS=yes COVERAGE=yes

    # cmd, with C:\msys64\mingw32\bin on PATH
    cd src\testdir
    set TEST_FILTER=Test_assert_equal_typed
    nmake -f Make_mvc.mak VIMPROG=..\gvim

## On the timing

The trigger was still the msys2 side. Between the last passing master run
(30983059032, 08-05 06:55Z) and the first failing one (31036852585, 08-05
18:53Z) the runner image and the workflows were unchanged, while `setup-msys2`
runs with `update: true`:

| package | pass | fail |
| --- | --- | --- |
| `mingw-w64-i686-crt` | 14.0.0.r220.gd999af622-1 | 14.0.0.r248.g7735a1a63-1 |
| `mingw-w64-i686-binutils` | 2.47-1 | 2.47-3 |
| `mingw-w64-i686-gcc` | 16.1.0-6 | 16.1.0-6 |

The CRT range is 28 commits reworking TLS and atexit (`crt/crtexe.c`,
`crt/tlssup.c`, `crt/tls_atexit.c`, ...), which is plausibly what made a
gcov-instrumented `_wsystem()` stop returning. I have not confirmed that, and
the fix above does not depend on it - but if someone wants to take it upstream,
that is where to look.
You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/20991

-- Commit Summary --

  * MinGW: tests hang when Vim is built with coverage enabled

-- File Changes --

    M src/Make_cyg_ming.mak (4)

-- Patch Links --

https://github.com/vim/vim/pull/20991.patch
https://github.com/vim/vim/pull/20991.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/20991
You are receiving this because you are subscribed to this thread.

Message ID: <vim/vim/pull/[email protected]>

-- 
-- 
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 visit https://groups.google.com/d/msgid/vim_dev/vim/vim/pull/20991%40github.com.