#GC Bug?
1 messages · Page 1 of 1 (latest)
import std.stdio;
int main() {
bool allocate = true;
int count = 50;
while (true) {
if(allocate && count > 0) {
ubyte[] block_of_data = new ubyte[100_000];
stderr.writeln(count);
count--;
}
}
return 0;
}
so an infinite loop infinitely loops?
no its what I was discussing in the programming chat
the GC uses up 100% of the cpu
even after the count is 0 and its no longer allocating
I made this post because I was going to put everything in it, I wasnt expecting to make the example so small, now its not really needed
so if you did like
else {
import core.thread;
Thread.sleep(1.seconds);
}
after the if(allocate) thing do you still see 100%
yes
ok interesting cuz that should take your main thread out of the running
yeah all threads are 100%
#programming message
this is where I was discussing it before. I was trying to clean it up so I could discuss it in one place now I just made a mess and I am discussing it in two places
but yeah its 100% across all threads
disabling the GC does cause it to stop
yeah it must be some like semaphore breakage in he thred. you test on linux too or only on windows?
only tested on windows 10 so far.
latest version of the compiler for dmd and ldc
LDC - the LLVM D compiler (1.42.0):
based on DMD v2.112.1 and LLVM 21.1.8
built with LDC - the LLVM D compiler (1.42.0)
DMD
D Compiler v2.112.0
yeah i can reproduce w/ upstream dmd
bug absent in opend
definitely a druntime regression then
i don't even have upstream dmd on my personal computer so i tested on the work computer lol but this kind of thing prolly affects day job company too
I naturally found when I allocated something in a graphical program. so something as simple as a button that loads a file can cause it
so yeah a fairly large issue
aye, it seems unbelievale to me they'd ship something so obviously broken
i'd notice this kind of thing instantly cuz i use my D programs all day every day and i'd hear my cpu fan spinning lol
i did not see the problem on WSL with same dmd version.
me@arsd:~/d/pull-request-stuff/dmd/druntime/src$ git show 14eed8d825a
me@arsd:~/d/pull-request-stuff/dmd/druntime/src$ git blame ./core/internal/gc/impl/conservative/gc.d
me@arsd:~/d/pull-request-stuff/dmd/druntime/src$ git show f90bf149c36
i haven't proven those commits are the problem but they're recent changes to the part of the code that would be hit in a loop like this, and the event and/or stop flags being wrong would explain an infinite loop like this
that isn't system specific but the implementation of Event varies between windows and posix so that's likely i would say where this went wrong
looks like the testsuite is terribly lacking
This flood of regressions looks worse than the Phobos regression witch hunt from 2025 — that targeted me and PRs from the salvaging queue.
just tested day job program too and it uses the newer gc and doesn't seem tobe affected sooooooooooo this is prolly where i stop cuz if they're not affected i can't really spin it as work-related to hunt down lol
and opend of course isn't affected cuz we don't pull regressions every other day
but still if someone wanted to pick it up from those commits i betcha you'd find the source soon enough
the author of those commits btw usually does good work and is i think a windows user; he maintains the visual-d thing. so might not be that specifically since he'd be mroe likely to catch sucha problem but still check it out
vladimir opened a bug about this last month using the slop machine
https://github.com/dlang/dmd/commit/e7a6f1b932af5b9d2ea885fe501f5a7906edf351
they claim it is fixed on master and the patch there looks reasonable