Skip to content

Processes permanently stuck in D state in brk/madvise → vma_merge → vma_start_write (leaked per-VMA lock) on kernel 6.18.33.2 #41708

Open

Description

@Ylin07

Windows Version

10.0.26200.8875

WSL Version

2.7.14.0 (also reproduced on 2.7.13.0 — both ship kernel 6.18.33.2-2)

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

6.18.33.2-2

Distro Version

Debian (WSL2, version 2), systemd=true

Other Software

Chromium 154.0.8037.57 built on Debian GNU/Linux 13 (trixie)

Repro Steps

Environment

  • Windows: 10.0.26200.8875
  • WSL: 2.7.14.0 (also reproduced on 2.7.13.0 — both ship kernel 6.18.33.2-2)
WSL  : 2.7.14.0
Kernel: 6.18.33.2-2
WSLg  : 1.0.73.2
MSRDC  : 1.2.7214
Direct3D  : 1.611.1-81528511
DXCore  : 10.0.26100.1-240331-1435.ge-release
Windows: 10.0.26200.8875
  • Kernel: Linux <host> 6.18.33.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 18 21:54:43 UTC 2026 x86_64 GNU/Linux
$ cat /proc/cmdline
initrd=\initrd.img WSL_ROOT_INIT=1 panic=-1 nr_cpus=6 hv_utils.timesync_implicit=1
console=hvc0 debug pty.legacy_count=0 WSL_ENABLE_CRASH_DUMP=1
  • Distro: Debian (WSL2), Ubuntu-24.04 also installed

%USERPROFILE%\.wslconfig (no kernel= / kernelCommandLine= overrides):

[wsl2]
memory=12GB
processors=6
swap=4GB

/etc/wsl.conf inside the distro:

[boot]
systemd=true
[user]
default=<user>

[interop]
enabled=true
appendWindowsPath=true

Relevant kernel config:

CONFIG_PER_VMA_LOCK=y
# CONFIG_PER_VMA_LOCK_STATS is not set
# CONFIG_PROVE_LOCKING is not set
# CONFIG_DEBUG_VM is not set
CONFIG_TRANSPARENT_HUGEPAGE=y     # /sys/kernel/mm/transparent_hugepage/enabled == [madvise]

Steps

  1. Start the distro (wsl -d Debian) and use it normally.
  2. Inside the distro, run any long-lived process with frequent VMA churn. It was reproduced
    with two unrelated programs:
    • @opencode/[email protected] — a bun build --compile standalone binary (embedded Bun 1.4.2)
    • Node.js v22.23.1 running chrome-devtools-mcp (plain node, no Bun involved)
  3. After roughly 10–15 minutes, monitor for D-state tasks.

Important: once the bug triggers, ps itself hangs forever (it blocks in
access_remote_vm()), so use a /proc-only scan instead:

cat /proc/loadavg

# D-state scan that does NOT block (do not use `ps`/`top` here)
for t in /proc/[0-9]*/task/[0-9]*; do
  s=$(cat "$t/stat" 2>/dev/null) || continue
  r="${s#*) }"
  if [ "${r%% *}" = "D" ]; then
    echo "tgid=$(echo $t | cut -d/ -f3) tid=$(echo $t | cut -d/ -f5) \
comm=$(cat $t/comm) wchan=$(cat $t/wchan)"
  fi
done
  1. Get the kernel stack of the stuck task as root (works even when the task is in D):
wsl -d Debian -u root -- cat /proc/<pid>/task/<tid>/stack
wsl -d Debian -u root -- cat /proc/<pid>/task/<tid>/syscall
  1. Try to kill it: kill -9 <pid> — it has no effect.
  2. The only way to clear it is wsl --terminate Debian / wsl --shutdown.

Note: not deterministic — it triggered spontaneously twice in the same kernel session,
on two different processes. No environment variables are required.

Expected Behavior

  • brk() and madvise() should complete normally. A task entering D state should be
    transient (bounded by the underlying I/O or lock hold time), not permanent.
    • SIGKILL should terminate the process.
    • No task should remain in uninterruptible sleep indefinitely; the process (and its sibling
      threads) should always be able to reach the exit path.
    • ps, top, and reads of /proc/<pid>/cmdline / /proc/<pid>/environ should not block
      on an unrelated process.
    • loadavg should reflect actual CPU usage — on this 6-vCPU VM it reached 21.8 while 0
      tasks were running and total CPU time was frozen.

Actual Behavior

Ordinary processes become permanently stuck in D (uninterruptible sleep) and are
immune to SIGKILL. ps/top and /proc/<pid>/cmdline|environ readers get wedged as well.
The whole WSL session becomes unusable and can only be recovered with wsl --terminate / wsl --shutdown.

The stuck task is always sleeping inside __vma_start_write(), reached from two different
syscall paths:

  • madvise() → madvise_walk_vmas() (per-VMA-lock walk)
  • brk() → do_brk_flags() → vma_merge_new_range() → vma_expand() →
    vma_start_write() → __vma_start_write()

Case 1 — Bun 1.4.2 (@opencode/[email protected])

19 threads of a single process stuck at once (all wchan values from /proc/<tid>/wchan):

tid=529      opencode.exe    D  wchan=__vma_start_write      <- main thread
tid=2322     JITWorker       D  wchan=madvise_walk_vmas
tid=2323     JITWorker       D  wchan=madvise_walk_vmas
tid=2324     JITWorker       D  wchan=madvise_walk_vmas
tid=531      mi-scavenger    D  wchan=madvise_walk_vmas
tid=539..543 HeapHelper      D  wchan=madvise_walk_vmas
tid=535..538 Bun Pool 0-3    D  wchan=do_exit
tid=564,565  opencode.exe    D  wchan=do_exit
tid=566      fs.watch        D  wchan=do_exit
tid=567      HTTP Client     D  wchan=do_exit
tid=2312     JSCWarmUp       D  wchan=do_exit

Result: 22 D tasks in total (19 threads + 3 stuck ps), loadavg 21.8 on a 6-vCPU
VM, 0 running tasks, and utime/stime of the victim frozen across repeated 5-second
samples (947/251 → 947/251).

Case 2 — Node.js v22.23.1 (chrome-devtools-mcp)

Kernel stack of the main thread:

$ wsl -d Debian -u root -- cat /proc/<pid>/task/<tid>/stack
[<0>] __vma_start_write+0x66/0x110
[<0>] vma_expand+0x5b/0x1d0
[<0>] vma_merge_new_range+0x79/0x160
[<0>] do_brk_flags+0x2e7/0x360
[<0>] __do_sys_brk+0x2c3/0x3e0
[<0>] __x64_sys_brk+0x16/0x20
[<0>] x64_sys_call+0x1aaf/0x20f0
[<0>] do_syscall_64+0x73/0x990
[<0>] entry_SYSCALL_64_after_hwframe+0x76/0x7e
$ cat /proc/<pid>/syscall
12 0xce85000 0x7915c9d01ac0 0x0 0x7915c9d01ac0 0x28000 0x1 0x7ffc44b73828 0x7915c9c21877

ORIG_RAX = 0xc = syscall 12 = brk; R8 = 0x28000 = a 160 KiB heap growth from
glibc malloc.

Full echo w > /proc/sysrq-trigger dump (abridged):

[  827.305161] sysrq: Show Blocked State
[  827.305979] task:chrome-devtools state:D stack:0  pid:7251  tgid:7251  ppid:5019
[  827.305983] Call Trace:
[  827.305984]  <TASK>
[  827.305987]  __schedule+0x546/0xc20
[  827.305992]  schedule+0x2b/0xf0
[  827.305993]  __vma_start_write+0x66/0x110
[  827.305995]  vma_expand+0x5b/0x1d0
[  827.305997]  vma_merge_new_range+0x79/0x160
[  827.305999]  do_brk_flags+0x2e7/0x360
[  827.306001]  __do_sys_brk+0x2c3/0x3e0
[  827.306002]  __x64_sys_brk+0x16/0x20
[  827.306004]  x64_sys_call+0x1aaf/0x20f0
[  827.306006]  do_syscall_64+0x73/0x990
[  827.306027] RIP: 0033:0x7915c9c21877
[  827.306029] RSP: 002b:00007ffc44b73828 EFLAGS: 00000206 ORIG_RAX: 000000000000000c
[  827.306031] RBP: 000000000ce5d000 R08: 0000000000028000 R09: 0000000000000001
[  827.306034]  </TASK>

All sibling threads were idle — no other thread of the process was in any mm code path:

tid=418 DelayedTaskSche  S  wchan=do_epoll_wait
tid=419 node             S  wchan=futex_do_wait
tid=420 node             S  wchan=futex_do_wait
tid=421 node             S  wchan=futex_do_wait
tid=422 node             S  wchan=futex_do_wait
tid=431 node             S  wchan=futex_do_wait

After kill -9 <pid> (which has no effect), the same 6 threads moved to D, stuck in
exit_mm() because the victim holds mmap_write_lock:

[  848.699041] task:node  state:D stack:0  pid:7266  tgid:7251  ppid:5019
[  848.699195]  __schedule+0x546/0xc20
[  848.699198]  schedule+0x2b/0xf0
[  848.699198]  schedule_preempt_disabled+0x19/0x30
[  848.699200]  rwsem_down_read_slowpath+0x289/0x560
[  848.699201]  down_read+0x4c/0xc0
[  848.699201]  do_exit+0x216/0xad0
[  848.699202]  do_group_exit+0x38/0x90
[  848.699203]  get_signal+0x89a/0x8a0

And a concurrent ps reading /proc/<pid>/environ is stuck behind the same lock:

[  827.306227] task:ps    state:D stack:0  pid:9593  tgid:9593  ppid:9581
[  827.306232]  schedule_preempt_disabled+0x19/0x30
[  827.306233]  rwsem_down_read_slowpath+0x289/0x560
[  827.306234]  down_read_killable+0x4c/0xd0
[  827.306235]  __access_remote_vm+0x4d/0x330
[  827.306236]  access_remote_vm+0x12/0x20
[  827.306237]  environ_read+0x18c/0x210
[  827.306239]  vfs_read+0xbf/0x350
[  827.306244]  ksys_read+0x6d/0xe0

Memory pressure is not the cause

Sampled while the task had been in D for ≥800 s:

$ cat /proc/pressure/memory
some avg10=0.00 avg60=0.00 avg300=0.00 total=0
full avg10=0.00 avg60=0.00 avg300=0.00 total=0

$ grep -E 'allocstall|pgscan_direct|pgsteal_direct|compact_stall' /proc/vmstat
allocstall_dma32 0
allocstall_normal 0
allocstall_movable 0
allocstall_device 0
pgsteal_direct 0
pgscan_direct 0
pgscan_direct_throttle 0
compact_stall 0

$ grep nr_free_pages /proc/vmstat
nr_free_pages 2832120          # ≈ 10.8 GB free

No allocation stalls, no direct reclaim, no compaction stalls, ~10.8 GB free pages. So the
sleep inside __vma_start_write() is not a kmem_cache_alloc()/reclaim stall — it is the
per-VMA lock acquisition. Since no thread of the process is in any mm path, the per-VMA write
lock has no live owner, i.e. it appears to be leaked.

Diagnostic Logs

Attached:

  • sysrq-w.txt — full output of echo w > /proc/sysrq-trigger + dmesg, captured while 8
    tasks
    were stuck (both cases above in one dump).

Collected from the affected distro:

wsl -d Debian -u root -- cat /proc/<pid>/task/<tid>/stack
wsl -d Debian -u root -- cat /proc/<pid>/task/<tid>/syscall
wsl -d Debian -u root -- sh -c 'echo w > /proc/sysrq-trigger; sleep 3; dmesg'

Other diagnostics gathered while stuck:

# load average at the time (0 running tasks, 22 D-state tasks)
$ cat /proc/loadavg
21.83 18.40 10.56 1/323 4136

# kernel command line
$ cat /proc/cmdline
initrd=\initrd.img WSL_ROOT_INIT=1 panic=-1 nr_cpus=6 hv_utils.timesync_implicit=1
console=hvc0 debug pty.legacy_count=0 WSL_ENABLE_CRASH_DUMP=1

# kernel config
CONFIG_PER_VMA_LOCK=y
# CONFIG_PER_VMA_LOCK_STATS is not set
# CONFIG_PROVE_LOCKING is not set
# CONFIG_DEBUG_VM is not set

# kallsyms
ffffffffba5aded0 T __vma_start_write
ffffffffba5e0ce0 T vma_expand
ffffffffba5e0ec0 T vma_merge_new_range
ffffffffba5e36a0 T do_brk_flags

Notes for triage:

  • CONFIG_PROVE_LOCKING is not set, so sysrq-d (dump all held locks) produces no output;
    there is no way to identify the lock owner from userspace.
  • wsl --update --rollback does not change the kernel: both 2.7.13.0 and 2.7.14.0
    ship kernel 6.18.33.2-2, so rolling back does not work around this.
  • The suspicion is the per-VMA lock state machine used by the newer VMA-merge path
    (vma_merge_new_range() / vma_expand()): the two observed cases differ only in the
    entry syscall (madvise vs brk) but both end up in __vma_start_write()

sysrq-w.txt

Activity

  1. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

    Once completed please upload the output files to this GitHub issue.

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  2. Ylin07 commented on Sep 26, 2026

    @Ylin07
    Author

    Attached are the logs collected using the official collect-wsl-logs.ps1 script.

    This is a bug report. I added /question by mistake; please disregard that command.

    WslLogs-2026-09-26_20-40-33.tar.gz

  3. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor
    Diagnostic information
    Found '/question', adding tag 'question'
    .wslconfig found
    Detected appx version: 2.7.14.0
    
  4. Ylin07 commented on Sep 26, 2026

    @Ylin07
    Author

    Attached are the logs collected using the official collect-wsl-logs.ps1 script.

    This issue reports a reproducible WSL2 hang, not a usage question. The question label was applied accidentally. Could a maintainer please remove it and triage this as a bug?

  5. Ylin07 commented on Sep 26, 2026

    @Ylin07
    Author

    Known good : 6.6.114.1-microsoft-standard-WSL2 (2025-12-01)
    Known bad : 6.18.33.2-microsoft-standard-WSL2 (2026-06-19)

    Symbol comparison:
    6.6.114.1 : vma_merge_new_range ABSENT
    __vma_start_write ABSENT
    madvise_walk_vmas ABSENT
    vma_merge / vma_expand present (old mm code)
    6.18.33.2 : vma_merge_new_range T ffffffffba5e0ec0
    __vma_start_write T ffffffffba5aded0
    madvise_walk_vmas t ffffffffba60d620
    vma_expand T ffffffffba5e0ce0

    Regression window: between 6.6.114.1 (2025-12-01) and 6.18.33.2 (2026-06-19).
    Confirmed on this machine: issue started 2026-06-18, exactly when WSL
    replaced tools/kernel with the 6.18.33.2 artifact.

    Workaround (in production here): pin
    kernel=...\6.6.114.1\kernel
    kernelModules=...\6.6.114.1\modules.vhd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kernel

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions