From 1b0af1ee6030b233eba7d29629c5ea995d5df944 Mon Sep 17 00:00:00 2001 From: Steven Schveighoffer Date: Mon, 18 Jun 2018 09:34:22 -0400 Subject: [PATCH] Fix issue 18996 - ProtoGC should support removing roots and ranges that were not originally added. Behavior is now consistent with conservative GC. --- src/gc/impl/proto/gc.d | 2 -- test/init_fini/Makefile | 2 +- test/init_fini/src/test18996.d | 13 +++++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 test/init_fini/src/test18996.d diff --git a/src/gc/impl/proto/gc.d b/src/gc/impl/proto/gc.d index fa879a88c7..e23e38f7f9 100644 --- a/src/gc/impl/proto/gc.d +++ b/src/gc/impl/proto/gc.d @@ -177,7 +177,6 @@ class ProtoGC : GC return; } } - assert(false); } @property RootIterator rootIter() return @nogc @@ -211,7 +210,6 @@ class ProtoGC : GC return; } } - assert(false); } @property RangeIterator rangeIter() return @nogc diff --git a/test/init_fini/Makefile b/test/init_fini/Makefile index 20ccdbd8a6..6f01a13cd0 100644 --- a/test/init_fini/Makefile +++ b/test/init_fini/Makefile @@ -1,6 +1,6 @@ include ../common.mak -TESTS:=thread_join runtime_args +TESTS:=thread_join runtime_args test18996 .PHONY: all clean all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) diff --git a/test/init_fini/src/test18996.d b/test/init_fini/src/test18996.d new file mode 100644 index 0000000000..01d514cd56 --- /dev/null +++ b/test/init_fini/src/test18996.d @@ -0,0 +1,13 @@ +// Issue https://issues.dlang.org/show_bug.cgi?id=18996 +// Array!string calls removeRange without first adding the range, but never +// initializes the GC. The behavior of the default GC is to ignore removing +// ranges when the range wasn't added. The ProtoGC originally would crash when +// this happened. + +import core.memory; + +void main() +{ + GC.removeRange(null); + GC.removeRoot(null); +}