Pure-D / serve-d

D LSP server (dlang language server protocol server)
MIT License
200 stars 48 forks source link

serve-d doesn't close when closing VSCode #186

Closed dkorpel closed 2 years ago

dkorpel commented 2 years ago

When I close VSCode or switch to a different workspace, an orphaned serve-d process stays active using 25% CPU (I have 4 cores). I'm on Debian Linux.

This might be a duplicate of https://github.com/Pure-D/serve-d/issues/185

I changed my serve-d executable to one with debug symbols that I built with dub from master, attached gdb, and got this backtrace:

(gdb) thread apply all bt

Thread 14 (Thread 0x7ff550efe700 (LWP 8535) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7ff551e63700) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7ff551e63618, cond=0x7ff551e636d8) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7ff551e636d8, mutex=0x7ff551e63618) at pthread_cond_wait.c:638
#3  0x0000557267974111 in core.sync.condition.Condition.wait() ()
#4  0x0000557267925f4b in std.parallelism.TaskPool.wait() ()
#5  0x0000557267925a9f in std.parallelism.TaskPool.pop() ()
#6  0x0000557267925a2b in std.parallelism.TaskPool.executeWorkLoop() ()
#7  0x0000557267925a04 in std.parallelism.TaskPool.startWorkLoop() ()
#8  0x000055726790b955 in core.thread.context.Callable.opCall() ()
#9  0x000055726790b433 in thread_entryPoint ()
#10 0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#11 0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 13 (Thread 0x7ff553fff700 (LWP 8534) "serve-d"):
#0  __GI___libc_read (nbytes=4096, buf=0x557268b0eb20, fd=10) at ../sysdeps/unix/sysv/linux/read.c:26
#1  __GI___libc_read (fd=10, buf=0x557268b0eb20, nbytes=4096) at ../sysdeps/unix/sysv/linux/read.c:24
#2  0x00007ff58495389a in _IO_new_file_underflow (fp=0x557268b26c80) at libioP.h:948
#3  0x00007ff584947918 in _IO_getdelim (lineptr=0x7ff553fff4d0, n=0x7ff553fff4d8, delimiter=10, fp=0x557268b26--Type <RET> for more, q to quit, c to continue without paging--c
c80) at iogetdelim.c:73
#4  0x0000557267932fea in std.stdio.readlnImpl(shared(core.stdc.stdio._IO_FILE)*, ref char[], dchar, std.stdio.File.Orientation) ()
#5  0x0000557267201f02 in std.stdio.File.readln!(char).readln(ref char[], dchar) (this=..., terminator=10 U'\n', buf=...) at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/stdio.d:1998
#6  0x0000557267515dd6 in std.stdio.File.readln!(immutable(char)[]).readln(dchar) (this=..., terminator=10 U'\n') at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/stdio.d:1856
#7  0x0000557267452f92 in workspaced.com.dcd.DCDComponent.startServer(immutable(char)[][], bool, bool).__lambda15() (__capture=0x7ff551e61330) at /home/dennis/.dub/packages/workspace-d-3.6.1/workspace-d/source/workspaced/com/dcd.d:235
#8  0x000055726754827f in std.parallelism.run!(void() delegate).run(void() delegate) (fpOrDelegate=...) at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/parallelism.d:754
#9  0x0000557267547ccc in std.parallelism.Task!(std.parallelism.run, void() delegate).Task.impl(void*) (myTask=0x7ff551e63780) at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/parallelism.d:436
#10 0x00005572679257af in std.parallelism.AbstractTask.job() ()
#11 0x00005572679258ec in std.parallelism.TaskPool.doJob(std.parallelism.AbstractTask*) ()
#12 0x0000557267925a5b in std.parallelism.TaskPool.executeWorkLoop() ()
#13 0x0000557267925a04 in std.parallelism.TaskPool.startWorkLoop() ()
#14 0x000055726790b955 in core.thread.context.Callable.opCall() ()
#15 0x000055726790b433 in thread_entryPoint ()
#16 0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#17 0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 12 (Thread 0x7ff564afc700 (LWP 8515) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7ff5834baca4) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7ff5834ba378, cond=0x7ff5834bac78) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7ff5834bac78, mutex=0x7ff5834ba378) at pthread_cond_wait.c:638
#3  0x0000557267974111 in core.sync.condition.Condition.wait() ()
#4  0x0000557267925f4b in std.parallelism.TaskPool.wait() ()
#5  0x0000557267925a9f in std.parallelism.TaskPool.pop() ()
#6  0x0000557267925a2b in std.parallelism.TaskPool.executeWorkLoop() ()
#7  0x0000557267925a04 in std.parallelism.TaskPool.startWorkLoop() ()
#8  0x000055726790b955 in core.thread.context.Callable.opCall() ()
#9  0x000055726790b433 in thread_entryPoint ()
#10 0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#11 0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 11 (Thread 0x7ff5652fd700 (LWP 8514) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7ff5834baca0) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7ff5834ba378, cond=0x7ff5834bac78) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7ff5834bac78, mutex=0x7ff5834ba378) at pthread_cond_wait.c:638
#3  0x0000557267974111 in core.sync.condition.Condition.wait() ()
#4  0x0000557267925f4b in std.parallelism.TaskPool.wait() ()
#5  0x0000557267925a9f in std.parallelism.TaskPool.pop() ()
#6  0x0000557267925a2b in std.parallelism.TaskPool.executeWorkLoop() ()
#7  0x0000557267925a04 in std.parallelism.TaskPool.startWorkLoop() ()
#8  0x000055726790b955 in core.thread.context.Callable.opCall() ()
#9  0x000055726790b433 in thread_entryPoint ()
#10 0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#11 0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 10 (Thread 0x7ff565afe700 (LWP 8513) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7ff5834baca4) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7ff5834ba378, cond=0x7ff5834bac78) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7ff5834bac78, mutex=0x7ff5834ba378) at pthread_cond_wait.c:638
#3  0x0000557267974111 in core.sync.condition.Condition.wait() ()
#4  0x0000557267925f4b in std.parallelism.TaskPool.wait() ()
#5  0x0000557267925a9f in std.parallelism.TaskPool.pop() ()
#6  0x0000557267925a2b in std.parallelism.TaskPool.executeWorkLoop() ()
#7  0x0000557267925a04 in std.parallelism.TaskPool.startWorkLoop() ()
#8  0x000055726790b955 in core.thread.context.Callable.opCall() ()
#9  0x000055726790b433 in thread_entryPoint ()
#10 0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#11 0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 9 (Thread 0x7ff5662ff700 (LWP 8512) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7ff5835606a0) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7ff58356c7f8, cond=0x7ff583560678) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7ff583560678, mutex=0x7ff58356c7f8) at pthread_cond_wait.c:638
#3  0x0000557267974111 in core.sync.condition.Condition.wait() ()
#4  0x0000557267925f4b in std.parallelism.TaskPool.wait() ()
#5  0x0000557267925a9f in std.parallelism.TaskPool.pop() ()
#6  0x0000557267925a2b in std.parallelism.TaskPool.executeWorkLoop() ()
#7  0x0000557267925a04 in std.parallelism.TaskPool.startWorkLoop() ()
#8  0x000055726790b955 in core.thread.context.Callable.opCall() ()
#9  0x000055726790b433 in thread_entryPoint ()
#10 0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#11 0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 8 (Thread 0x7ff580a3d700 (LWP 8511) "serve-d"):
#0  __GI___libc_read (nbytes=4096, buf=0x557268af6fc0, fd=8) at ../sysdeps/unix/sysv/linux/read.c:26
#1  __GI___libc_read (fd=8, buf=0x557268af6fc0, nbytes=4096) at ../sysdeps/unix/sysv/linux/read.c:24
#2  0x00007ff58495389a in _IO_new_file_underflow (fp=0x557268b16360) at libioP.h:948
#3  0x00007ff584947918 in _IO_getdelim (lineptr=0x7ff580a3d4d0, n=0x7ff580a3d4d8, delimiter=10, fp=0x557268b16360) at iogetdelim.c:73
#4  0x0000557267932fea in std.stdio.readlnImpl(shared(core.stdc.stdio._IO_FILE)*, ref char[], dchar, std.stdio.File.Orientation) ()
#5  0x0000557267201f02 in std.stdio.File.readln!(char).readln(ref char[], dchar) (this=..., terminator=10 U'\n', buf=...) at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/stdio.d:1998
#6  0x0000557267515dd6 in std.stdio.File.readln!(immutable(char)[]).readln(dchar) (this=..., terminator=10 U'\n') at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/stdio.d:1856
#7  0x0000557267452f92 in workspaced.com.dcd.DCDComponent.startServer(immutable(char)[][], bool, bool).__lambda15() (__capture=0x7ff58340d540) at /home/dennis/.dub/packages/workspace-d-3.6.1/workspace-d/source/workspaced/com/dcd.d:235
#8  0x000055726754827f in std.parallelism.run!(void() delegate).run(void() delegate) (fpOrDelegate=...) at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/parallelism.d:754
#9  0x0000557267547ccc in std.parallelism.Task!(std.parallelism.run, void() delegate).Task.impl(void*) (myTask=0x7ff58355d000) at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/parallelism.d:436
#10 0x00005572679257af in std.parallelism.AbstractTask.job() ()
#11 0x00005572679258ec in std.parallelism.TaskPool.doJob(std.parallelism.AbstractTask*) ()
#12 0x0000557267925a5b in std.parallelism.TaskPool.executeWorkLoop() ()
#13 0x0000557267925a04 in std.parallelism.TaskPool.startWorkLoop() ()
#14 0x000055726790b955 in core.thread.context.Callable.opCall() ()
#15 0x000055726790b433 in thread_entryPoint ()
#16 0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#17 0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 7 (Thread 0x7ff581e8b700 (LWP 8466) "serve-d"):
#0  __GI___libc_read (nbytes=4096, buf=0x5572689eaab0, fd=6) at ../sysdeps/unix/sysv/linux/read.c:26
#1  __GI___libc_read (fd=6, buf=0x5572689eaab0, nbytes=4096) at ../sysdeps/unix/sysv/linux/read.c:24
#2  0x00007ff58495389a in _IO_new_file_underflow (fp=0x5572689ea6d0) at libioP.h:948
#3  0x00007ff584947918 in _IO_getdelim (lineptr=0x7ff581e8b4d0, n=0x7ff581e8b4d8, delimiter=10, fp=0x5572689ea6d0) at iogetdelim.c:73
#4  0x0000557267932fea in std.stdio.readlnImpl(shared(core.stdc.stdio._IO_FILE)*, ref char[], dchar, std.stdio.File.Orientation) ()
#5  0x0000557267201f02 in std.stdio.File.readln!(char).readln(ref char[], dchar) (this=..., terminator=10 U'\n', buf=...) at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/stdio.d:1998
#6  0x0000557267515dd6 in std.stdio.File.readln!(immutable(char)[]).readln(dchar) (this=..., terminator=10 U'\n') at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/stdio.d:1856
#7  0x0000557267452f92 in workspaced.com.dcd.DCDComponent.startServer(immutable(char)[][], bool, bool).__lambda15() (__capture=0x7ff582daf420) at /home/dennis/.dub/packages/workspace-d-3.6.1/workspace-d/source/workspaced/com/dcd.d:235
#8  0x000055726754827f in std.parallelism.run!(void() delegate).run(void() delegate) (fpOrDelegate=...) at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/parallelism.d:754
#9  0x0000557267547ccc in std.parallelism.Task!(std.parallelism.run, void() delegate).Task.impl(void*) (myTask=0x7ff5826f1600) at /home/dennis/dlang/dmd2/linux/bin64/../../src/phobos/std/parallelism.d:436
#10 0x00005572679257af in std.parallelism.AbstractTask.job() ()
#11 0x00005572679258ec in std.parallelism.TaskPool.doJob(std.parallelism.AbstractTask*) ()
#12 0x0000557267925a5b in std.parallelism.TaskPool.executeWorkLoop() ()
#13 0x0000557267925a04 in std.parallelism.TaskPool.startWorkLoop() ()
#14 0x000055726790b955 in core.thread.context.Callable.opCall() ()
#15 0x000055726790b433 in thread_entryPoint ()
#16 0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#17 0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 6 (Thread 0x7ff58268c700 (LWP 8465) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7ff5826f1580) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7ff5826f1498, cond=0x7ff5826f1558) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7ff5826f1558, mutex=0x7ff5826f1498) at pthread_cond_wait.c:638
#3  0x0000557267974111 in core.sync.condition.Condition.wait() ()
#4  0x0000557267925f4b in std.parallelism.TaskPool.wait() ()
#5  0x0000557267925a9f in std.parallelism.TaskPool.pop() ()
#6  0x0000557267925a2b in std.parallelism.TaskPool.executeWorkLoop() ()
#7  0x0000557267925a04 in std.parallelism.TaskPool.startWorkLoop() ()
#8  0x000055726790b955 in core.thread.context.Callable.opCall() ()
#9  0x000055726790b433 in thread_entryPoint ()
#10 0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#11 0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 5 (Thread 0x7ff5837b9700 (LWP 8438) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x55726899d68c) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x55726899d638, cond=0x55726899d660) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x55726899d660, mutex=0x55726899d638) at pthread_cond_wait.c:638
#3  0x00005572679cc915 in core.sync.event.Event.wait(core.time.Duration) ()
#4  0x00005572679c67bc in core.internal.gc.impl.conservative.gc.Gcx.scanBackground() ()
#5  0x00005572679ccfd4 in core.thread.osthread.createLowLevelThread(void() nothrow delegate, uint, void() nothrow delegate).thread_lowlevelEntry(void*) ()
#6  0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#7  0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 4 (Thread 0x7ff5837c1700 (LWP 8437) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x55726899d68c) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x55726899d638, cond=0x55726899d660) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x55726899d660, mutex=0x55726899d638) at pthread_cond_wait.c:638
#3  0x00005572679cc915 in core.sync.event.Event.wait(core.time.Duration) ()
#4  0x00005572679c67bc in core.internal.gc.impl.conservative.gc.Gcx.scanBackground() ()
#5  0x00005572679ccfd4 in core.thread.osthread.createLowLevelThread(void() nothrow delegate, uint, void() nothrow delegate).thread_lowlevelEntry(void*) ()
#6  0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#7  0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7ff584c35700 (LWP 8436) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x55726899d68c) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x55726899d638, cond=0x55726899d660) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x55726899d660, mutex=0x55726899d638) at pthread_cond_wait.c:638
#3  0x00005572679cc915 in core.sync.event.Event.wait(core.time.Duration) ()
#4  0x00005572679c67bc in core.internal.gc.impl.conservative.gc.Gcx.scanBackground() ()
#5  0x00005572679ccfd4 in core.thread.osthread.createLowLevelThread(void() nothrow delegate, uint, void() nothrow delegate).thread_lowlevelEntry(void*) ()
#6  0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#7  0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7ff584043700 (LWP 8434) "serve-d"):
#0  0x00007ff5849c78b3 in __GI___select (nfds=1, readfds=0x7ff584040d40, writefds=0x0, exceptfds=0x0, timeout=0x7ff584040dc0) at ../sysdeps/unix/sysv/linux/select.c:41
#1  0x00005572673f5556 in served.lsp.filereader.PosixStdinReader.run() (this=0x7ff5847eef00) at lsp/source/served/lsp/filereader.d:145
#2  0x000055726790b955 in core.thread.context.Callable.opCall() ()
#3  0x000055726790b433 in thread_entryPoint ()
#4  0x00007ff584c0eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#5  0x00007ff5849cfdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7ff5848cd780 (LWP 8433) "serve-d"):
#0  0x00007ff584997c61 in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=0x7ffd31e19280, rem=0x7ffd31e19290) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:48
#1  0x00007ff58499d443 in __GI___nanosleep (requested_time=<optimized out>, remaining=<optimized out>) at nanosleep.c:27
#2  0x000055726790b264 in core.thread.osthread.Thread.sleep(core.time.Duration) ()
#3  0x00005572672fe3aa in served.types.lspRouter.run() () at serverbase/source/served/serverbase.d:461
#4  0x000055726717d94d in D main (args=...) at source/app.d:189
WebFreak001 commented 2 years ago

closing as duplicate of #185 as likely the issue, but feel free to reconfirm with 0.7.2 when released in a minute and reopen if needed.

dkorpel commented 2 years ago

VSCode auto-installed serve-d_0.7.3, and the issue looks gone!

dkorpel commented 2 years ago

Seems like I celebrated too early, I still have this issue :(

WebFreak001 commented 2 years ago

can you send updated stacktrace of all threads again?

It doesn't seem very easily reproducible the minimal test server I have for debugging this kind of issue also closes without issue.

dkorpel commented 2 years ago
(gdb) thread apply all bt

Thread 4 (Thread 0x7fa811d45700 (LWP 27402) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x5570650d3688) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x5570650d3638, cond=0x5570650d3660) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x5570650d3660, mutex=0x5570650d3638) at pthread_cond_wait.c:638
#3  0x0000557063d09225 in core.sync.event.Event.wait(core.time.Duration) ()
#4  0x0000557063d030cc in core.internal.gc.impl.conservative.gc.Gcx.scanBackground() ()
#5  0x0000557063d098e4 in core.thread.osthread.createLowLevelThread(void() nothrow delegate, uint, void() nothrow delegate).thread_lowlevelEntry(void*) ()
#6  0x00007fa81319aea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#7  0x00007fa812f5bdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7fa811d4d700 (LWP 27401) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x5570650d3688) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x5570650d3638, cond=0x5570650d3660) at pthread_cond_wait.c:508
--Type <RET> for more, q to quit, c to continue without paging--c
#2  __pthread_cond_wait (cond=0x5570650d3660, mutex=0x5570650d3638) at pthread_cond_wait.c:638
#3  0x0000557063d09225 in core.sync.event.Event.wait(core.time.Duration) ()
#4  0x0000557063d030cc in core.internal.gc.impl.conservative.gc.Gcx.scanBackground() ()
#5  0x0000557063d098e4 in core.thread.osthread.createLowLevelThread(void() nothrow delegate, uint, void() nothrow delegate).thread_lowlevelEntry(void*) ()
#6  0x00007fa81319aea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#7  0x00007fa812f5bdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7fa8131c1700 (LWP 27400) "serve-d"):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x5570650d3688) at ../sysdeps/nptl/futex-internal.h:186
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x5570650d3638, cond=0x5570650d3660) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x5570650d3660, mutex=0x5570650d3638) at pthread_cond_wait.c:638
#3  0x0000557063d09225 in core.sync.event.Event.wait(core.time.Duration) ()
#4  0x0000557063d030cc in core.internal.gc.impl.conservative.gc.Gcx.scanBackground() ()
#5  0x0000557063d098e4 in core.thread.osthread.createLowLevelThread(void() nothrow delegate, uint, void() nothrow delegate).thread_lowlevelEntry(void*) ()
#6  0x00007fa81319aea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#7  0x00007fa812f5bdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7fa812e59780 (LWP 27392) "serve-d"):
#0  0x0000557063cfdb1c in core.internal.gc.impl.conservative.gc.ConservativeGC.qalloc(ulong, uint, scope const(TypeInfo)) ()
#1  0x0000557063c45197 in gc_qalloc ()
#2  0x0000557063cb3920 in rt.lifetime.__arrayAlloc(ulong, scope const(TypeInfo), const(TypeInfo)) ()
#3  0x0000557063c4f526 in _d_arrayliteralTX ()
#4  0x0000557063731bc0 in served.lsp.filereader.FileReader.yieldLine() (this=0x7fa812d7af00) at lsp/source/served/lsp/filereader.d:204
#5  0x0000557063737224 in served.lsp.jsonrpc.RPCProcessor.run() (this=0x7fa812dab370) at lsp/source/served/lsp/jsonrpc.d:255
#6  0x0000557063c48261 in core.thread.context.Callable.opCall() ()
#7  0x0000557063cb1874 in fiber_entryPoint ()
#8  0x0000000000000000 in ?? ()
dkorpel commented 2 years ago

This is with serve-d set to a debug build from the master branch (dub build), and after opening the repository of dlang/dmd in VSCode and closing it.

WebFreak001 commented 2 years ago

I can't reproduce it with dlang/dmd on my machine

With the backtrace you sent it also shouldn't max out any CPU (there is only 1 thread other than GC thread in your post and that thread is in "yieldLine" which calls Fiber.yield, where the scheduler will always Thread.sleep for 10ms on every yield)

The question is why it's stuck there. I have made a small patch at an attempt to fix this, (checkout master / 8128219c5dcab885488559dd8ca73d292212e758) but if that doesn't work you should add a breakpoint at FileReader.yieldLine (filereader.d:201) and PosixStdinReader.isReading (filereader.d:181) to see how it's stepping. A video would be nice if you can step through there.

Also do dub upgrade before calling dub build to make sure that dub actually fetched the specified dependency versions.

WebFreak001 commented 2 years ago

confirmed fixed (with other version reproducing) by Mali Laurent on Discord now.

Released a new version so you can try it out soon and it should be fixed.

dkorpel commented 2 years ago

So far I didn't stumble on this anymore, so I'm hopeful.

GrimMaple commented 2 years ago

+1, I had a similar issue on my Linux laptop. Currently rocking serve-d-0.7.4 and the issue is gone