Skip to content

Commit ee68d84

Browse files
authored
Merge pull request #4993 from WalterWaldron/fix16352
Addendum PR4988 - dead-lock in std.allocator.free_list unittest
2 parents b95b67a + f7e14e9 commit ee68d84

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

std/experimental/allocator/building_blocks/free_list.d

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,37 +1039,33 @@ struct SharedFreeList(ParentAllocator,
10391039
unittest
10401040
{
10411041
import std.algorithm.comparison : equal;
1042-
import std.concurrency : receiveOnly, send, spawn, thisTid, Tid;
10431042
import std.range : repeat;
10441043
import std.experimental.allocator.mallocator : Mallocator;
1044+
import core.thread : ThreadGroup;
10451045

10461046
static shared SharedFreeList!(Mallocator, 64, 128, 10) a;
10471047

10481048
assert(a.goodAllocSize(1) == platformAlignment);
10491049

1050-
auto b = a.allocate(100);
1050+
auto b = a.allocate(96);
10511051
a.deallocate(b);
10521052

1053-
static void fun(Tid tid, int i)
1053+
void fun()
10541054
{
1055-
scope(exit) tid.send(true);
1056-
auto b = cast(ubyte[]) a.allocate(100);
1057-
b[] = cast(ubyte) i;
1055+
auto b = cast(size_t[]) a.allocate(96);
1056+
b[] = cast(size_t) &b;
10581057

1059-
assert(b.equal(repeat(cast(ubyte) i, b.length)));
1058+
assert(b.equal(repeat(cast(size_t) &b, b.length)));
10601059
a.deallocate(b);
10611060
}
10621061

1063-
Tid[] tids;
1062+
auto tg = new ThreadGroup;
10641063
foreach (i; 0 .. 20)
10651064
{
1066-
tids ~= spawn(&fun, thisTid, i);
1065+
tg.create(&fun);
10671066
}
10681067

1069-
foreach (i; 0 .. 20)
1070-
{
1071-
assert(receiveOnly!bool);
1072-
}
1068+
tg.joinAll();
10731069
}
10741070

10751071
unittest

0 commit comments

Comments
 (0)