diff -Nru dcontainers-0.8.0~alpha.5/debian/changelog dcontainers-0.8.0~alpha.6/debian/changelog --- dcontainers-0.8.0~alpha.5/debian/changelog 2018-04-04 03:15:08.000000000 +0000 +++ dcontainers-0.8.0~alpha.6/debian/changelog 2018-04-23 21:04:26.000000000 +0000 @@ -1,3 +1,18 @@ +dcontainers (0.8.0~alpha.6-1) unstable; urgency=medium + + * New upstream version: 0.8.0~alpha.6 + * Drop patches: Applied upstream + + -- Matthias Klumpp Mon, 23 Apr 2018 23:04:26 +0200 + +dcontainers (0.8.0~alpha.5-3) unstable; urgency=medium + + * Update maintainer address to tracker.d.o + * fix-gc-hashmap-crash.patch: Fix crash in GC collection when + using a HashMap containing GC-managed elements + + -- Matthias Klumpp Fri, 20 Apr 2018 22:06:10 +0200 + dcontainers (0.8.0~alpha.5-2) unstable; urgency=medium * Make -dev package depend on libstdx-allocator-dev diff -Nru dcontainers-0.8.0~alpha.5/debian/control dcontainers-0.8.0~alpha.6/debian/control --- dcontainers-0.8.0~alpha.5/debian/control 2018-04-04 03:06:38.000000000 +0000 +++ dcontainers-0.8.0~alpha.6/debian/control 2018-04-20 21:53:47.000000000 +0000 @@ -1,14 +1,14 @@ Source: dcontainers Section: libs Priority: optional -Maintainer: Debian D Language Group +Maintainer: Debian D Language Group Uploaders: Matthias Klumpp Build-Depends: debhelper (>= 11), dh-dlang, libstdx-allocator-dev, meson (>= 0.45), pkg-config -Standards-Version: 4.1.2 +Standards-Version: 4.1.4 Homepage: https://github.com/dlang-community/containers Vcs-Browser: https://salsa.debian.org/d-team/dcontainers Vcs-Git: https://salsa.debian.org/d-team/dcontainers.git diff -Nru dcontainers-0.8.0~alpha.5/.gitignore dcontainers-0.8.0~alpha.6/.gitignore --- dcontainers-0.8.0~alpha.5/.gitignore 2018-03-27 22:27:23.000000000 +0000 +++ dcontainers-0.8.0~alpha.6/.gitignore 2018-04-23 18:39:45.000000000 +0000 @@ -13,6 +13,8 @@ test/compile_test_32 test/external_allocator_test test/external_allocator_test_32 +test/openhashset +test/hashmap_gc_test .gdb_history __test__*__ *.exe diff -Nru dcontainers-0.8.0~alpha.5/src/containers/hashmap.d dcontainers-0.8.0~alpha.6/src/containers/hashmap.d --- dcontainers-0.8.0~alpha.5/src/containers/hashmap.d 2018-03-27 22:27:23.000000000 +0000 +++ dcontainers-0.8.0~alpha.6/src/containers/hashmap.d 2018-04-23 18:39:45.000000000 +0000 @@ -97,9 +97,12 @@ { import stdx.allocator : dispose; - allocator.dispose(buckets); + // always remove ranges from GC first before disposing of buckets, to + // prevent segfaults when the GC collects at an unfortunate time static if (useGC) GC.removeRange(buckets.ptr); + allocator.dispose(buckets); + buckets = null; _length = 0; } diff -Nru dcontainers-0.8.0~alpha.5/src/containers/unrolledlist.d dcontainers-0.8.0~alpha.6/src/containers/unrolledlist.d --- dcontainers-0.8.0~alpha.5/src/containers/unrolledlist.d 2018-03-27 22:27:23.000000000 +0000 +++ dcontainers-0.8.0~alpha.6/src/containers/unrolledlist.d 2018-04-23 18:39:45.000000000 +0000 @@ -70,12 +70,13 @@ static if (!(is(T == class) || is(T == interface))) foreach (ref item; previous.items) typeid(T).destroy(&item); - allocator.dispose(previous); + static if (useGC) { import core.memory: GC; GC.removeRange(previous); } + allocator.dispose(previous); } _length = 0; _front = null; @@ -481,12 +482,12 @@ if (_back is n) _back = n.prev; - allocator.dispose(n); static if (useGC) { import core.memory: GC; GC.removeRange(n); } + allocator.dispose(n); } static bool shouldMerge(const Node* first, const Node* second) diff -Nru dcontainers-0.8.0~alpha.5/test/hashmap_gc_test.d dcontainers-0.8.0~alpha.6/test/hashmap_gc_test.d --- dcontainers-0.8.0~alpha.5/test/hashmap_gc_test.d 1970-01-01 00:00:00.000000000 +0000 +++ dcontainers-0.8.0~alpha.6/test/hashmap_gc_test.d 2018-04-23 18:39:45.000000000 +0000 @@ -0,0 +1,48 @@ + +import containers : HashMap; +import std.stdio : writefln; +import core.memory : GC; + + +/** + * Generate a random alphanumeric string. + */ +@trusted +string randomString (uint len) +{ + import std.ascii : letters, digits; + import std.conv : to; + import std.random : randomSample; + import std.range : chain; + + auto asciiLetters = to! (dchar[]) (letters); + auto asciiDigits = to! (dchar[]) (digits); + + if (len == 0) + len = 1; + + auto res = to!string (randomSample (chain (asciiLetters, asciiDigits), len)); + return res; +} + +void main () +{ + immutable iterationCount = 4; + HashMap!(string, string) hmap; + + for (uint n = 1; n <= iterationCount; n++) { + foreach (i; 0 .. 1_000_000) + hmap[randomString (4)] = randomString (16); + GC.collect (); + hmap = HashMap!(string, string) (16); + GC.collect (); + + foreach (i; 0 .. 1_000_000) + hmap[randomString (4)] = randomString (16); + GC.collect (); + hmap.clear (); + GC.collect (); + + writefln ("iteration %s/%s finished", n, iterationCount); + } +} diff -Nru dcontainers-0.8.0~alpha.5/test/makefile dcontainers-0.8.0~alpha.6/test/makefile --- dcontainers-0.8.0~alpha.5/test/makefile 2018-03-27 22:27:23.000000000 +0000 +++ dcontainers-0.8.0~alpha.6/test/makefile 2018-04-23 18:39:45.000000000 +0000 @@ -8,10 +8,11 @@ all: all_32 all_64 -all_64: test compile_test external_allocator_test +all_64: test compile_test external_allocator_test hashmap_gc_test ./tests ./compile_test ./external_allocator_test + ./hashmap_gc_test all_32: test_32 compile_test_32 external_allocator_test_32 ./tests_32 @@ -40,6 +41,13 @@ ../src/containers/internal/node.d \ -I../src/ \ +hashmap_gc_test: hashmap_gc_test.d $(SRC) + $(DC) -g -inline -O -release \ + -I../src/ -I../stdx-allocator/source -debug -wi \ + $(SRC) \ + hashmap_gc_test.d \ + -ofhashmap_gc_test + clean: rm -f tests rm -f *.o