mirror of
https://review.haiku-os.org/buildtools
synced 2025-02-15 02:07:42 +01:00
Updated dependencies: * GMP 6.2.1 * ISL 0.24 * MPL 1.2.1 * MPFR 4.1.0 The dependencies were pulled in by running the ./contrib/download_prerequisites script and then manually removing the symbolic links and archives, and renaming the directories (i.e mv isl-0.24 to isl)
71 lines
1.3 KiB
D
71 lines
1.3 KiB
D
import core.memory;
|
|
import core.sync.condition;
|
|
import core.sync.mutex;
|
|
import core.thread;
|
|
|
|
__gshared Condition g_cond;
|
|
__gshared Mutex g_mutex;
|
|
__gshared int g_step = 0;
|
|
|
|
class C
|
|
{
|
|
~this()
|
|
{
|
|
import core.stdc.stdlib;
|
|
abort(); // this gets triggered although the instance always stays referenced
|
|
}
|
|
}
|
|
|
|
C c;
|
|
|
|
static this()
|
|
{
|
|
c = new C;
|
|
}
|
|
|
|
static ~this()
|
|
{
|
|
import core.memory;
|
|
GC.free(cast(void*)c); // free without destruction to avoid triggering abort()
|
|
}
|
|
|
|
void test()
|
|
{
|
|
assert(c !is null);
|
|
|
|
// notify the main thread of the finished initialization
|
|
synchronized (g_mutex) g_step = 1;
|
|
g_cond.notifyAll();
|
|
|
|
// wait until the GC collection is done
|
|
synchronized (g_mutex) {
|
|
while (g_step != 2)
|
|
g_cond.wait();
|
|
}
|
|
}
|
|
|
|
|
|
void main()
|
|
{
|
|
g_mutex = new Mutex;
|
|
g_cond = new Condition(g_mutex);
|
|
|
|
auto th = new Thread(&test);
|
|
th.start();
|
|
|
|
// wait for thread to be fully initialized
|
|
synchronized (g_mutex) {
|
|
while (g_step != 1)
|
|
g_cond.wait();
|
|
}
|
|
|
|
// this causes the other thread's C instance to be reaped with the bug present
|
|
GC.collect();
|
|
|
|
// allow the thread to shut down
|
|
synchronized (g_mutex) g_step = 2;
|
|
g_cond.notifyAll();
|
|
|
|
th.join();
|
|
}
|