]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libphobos: Merge changes in upstream druntime testsuite
authorIain Buclaw <ibuclaw@gdcproject.org>
Sat, 15 Mar 2025 15:32:48 +0000 (16:32 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Tue, 18 Mar 2025 17:53:11 +0000 (18:53 +0100)
libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime d2ee11364c.
* testsuite/libphobos.aa/test_aa.d: Add new test.
* testsuite/libphobos.betterc/test19933.d: Adjust imports.
* testsuite/libphobos.config/test22523.d: Likewise.
* testsuite/libphobos.exceptions/assert_fail.d: Adjust test.
* testsuite/libphobos.exceptions/chain.d: Adjust imports.
* testsuite/libphobos.exceptions/future_message.d: Likewise.
* testsuite/libphobos.exceptions/line_trace.d: Likewise.
* testsuite/libphobos.exceptions/long_backtrace_trunc.d: Likewise.
* testsuite/libphobos.exceptions/static_dtor.d: Likewise.
* testsuite/libphobos.gc/forkgc.d: Likewise.
* testsuite/libphobos.gc/precisegc.d: Likewise.
* testsuite/libphobos.gc/recoverfree.d: Likewise.
* testsuite/libphobos.hash/test_hash.d: Likewise.
* testsuite/libphobos.init_fini/custom_gc.d: Likewise.
* testsuite/libphobos.init_fini/thread_join.d: Likewise.
* testsuite/libphobos.thread/external_threads.d: Likewise.
* testsuite/libphobos.thread/fiber_guard_page.d: Likewise.
* testsuite/libphobos.thread/tlsgc_sections.d: Likewise.
* testsuite/libphobos.thread/tlsstack.d: Likewise.
* testsuite/libphobos.unittest/customhandler.d: Likewise.

21 files changed:
libphobos/libdruntime/MERGE
libphobos/testsuite/libphobos.aa/test_aa.d
libphobos/testsuite/libphobos.betterc/test19933.d
libphobos/testsuite/libphobos.config/test22523.d
libphobos/testsuite/libphobos.exceptions/assert_fail.d
libphobos/testsuite/libphobos.exceptions/chain.d
libphobos/testsuite/libphobos.exceptions/future_message.d
libphobos/testsuite/libphobos.exceptions/line_trace.d
libphobos/testsuite/libphobos.exceptions/long_backtrace_trunc.d
libphobos/testsuite/libphobos.exceptions/static_dtor.d
libphobos/testsuite/libphobos.gc/forkgc.d
libphobos/testsuite/libphobos.gc/precisegc.d
libphobos/testsuite/libphobos.gc/recoverfree.d
libphobos/testsuite/libphobos.hash/test_hash.d
libphobos/testsuite/libphobos.init_fini/custom_gc.d
libphobos/testsuite/libphobos.init_fini/thread_join.d
libphobos/testsuite/libphobos.thread/external_threads.d
libphobos/testsuite/libphobos.thread/fiber_guard_page.d
libphobos/testsuite/libphobos.thread/tlsgc_sections.d
libphobos/testsuite/libphobos.thread/tlsstack.d
libphobos/testsuite/libphobos.unittest/customhandler.d

index 070d9fec28b9bf4673640e910c783e675ca214f8..18c9d1190cedadcc8cfe4c735e580db16e5e2e0a 100644 (file)
@@ -1,4 +1,4 @@
-603225372b211bb66dd0ea1a939043ace5a650cf
+d2ee11364c25ca8865eb0acb9596a6147532ef41
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index 11ad2f90ff1d00f4c17c3fe5f1320b87e7e7a809..5c3ba05d83d30b7d91c0259fe39f5df3949f5cbb 100644 (file)
@@ -40,6 +40,7 @@ void main()
     testZeroSizedValue();
     testTombstonePurging();
     testClear();
+    testTypeInfoCollect();
 }
 
 void testKeysValues1()
@@ -585,8 +586,6 @@ void issue13078() nothrow pure
 
 void issue14104()
 {
-    import core.stdc.stdio;
-
     alias K = const(ubyte)*;
     size_t[K] aa;
     immutable key = cast(K)(cast(size_t) uint.max + 1);
@@ -907,3 +906,44 @@ void testClear()
     assert(aa.length == 1);
     assert(aa[5] == 6);
 }
+
+// https://github.com/dlang/dmd/issues/17503
+void testTypeInfoCollect()
+{
+    import core.memory;
+
+    static struct S
+    {
+        int x;
+        ~this() {}
+    }
+
+    static struct AAHolder
+    {
+        S[int] aa;
+    }
+
+    static S* getBadS()
+    {
+        auto aaholder = new AAHolder;
+        aaholder.aa[0] = S();
+        auto s = 0 in aaholder.aa; // keep a pointer to the entry
+        GC.free(aaholder); // but not a pointer to the AA.
+        return s;
+    }
+
+    static void stackStomp()
+    {
+        import core.stdc.string : memset;
+        ubyte[4 * 4096] x;
+        memset(x.ptr, 0, x.sizeof);
+    }
+
+    auto s = getBadS();
+    stackStomp(); // destroy any stale references to the AA or s except in the current frame;
+    GC.collect(); // BUG: this used to invalidate the fake type info, should no longer do this.
+    foreach(i; 0 .. 1000) // try to reallocate the freed type info
+        auto p = new void*[1];
+    s = null; // clear any reference to the entry
+    GC.collect(); // used to segfault.
+}
index a0faadd211203537ae8fab7bab0a80af25ccd42b..d5c9eacf0df0833047a68e514eec947bec8ab3bf 100644 (file)
@@ -2,7 +2,7 @@
 // https://issues.dlang.org/show_bug.cgi?id=19933
 // https://issues.dlang.org/show_bug.cgi?id=18816
 
-import core.stdc.stdio;
+import core.stdc.stdio : fprintf, stderr;
 
 extern(C) int main()
 {
index f3086963f2e97950d715d188fd74cc3d0e601edd..680f573ce700e997eccd4fea2eff801dcf9e419c 100644 (file)
@@ -1,6 +1,6 @@
 // https://issues.dlang.org/show_bug.cgi?id=22523
 
-import core.stdc.stdio;
+import core.stdc.stdio : puts;
 
 int main()
 {
index 352ccca3901d28155b77e39b5fdcfd5097980640..ee5caf6e198f1b07d1bca721880740540c19c44e 100644 (file)
@@ -523,8 +523,16 @@ void testDestruction()
         new long[100];
     }
 
+    static void clobberStack()
+    {
+        ubyte[1024] clobber;
+        clobber[] = 0xff;
+    }
+
     import core.memory : GC;
     createGarbage();
+    // ensure there are no stale references on the stack
+    clobberStack();
     GC.collect();
 
     assert(Test.run);
index 0305707fc62aea6cad941b58a1b9e5ba9b5f0af3..d860ff072e0f15ff0a86f0b4b614b1a81c257140 100644 (file)
@@ -1,7 +1,7 @@
 // Author: Ali Ã‡ehreli
 // See https://forum.dlang.org/post/o2n7f8$2p1t$1@digitalmars.com
 
-import core.stdc.stdio;
+import core.stdc.stdio : printf;
 
 class TestException : Exception
 {
index 61b1034828720ae97b6615bed8a264ee5e4d6901..65a6b5633cf7374587238e3b012e8a46d9b8d98a 100644 (file)
@@ -1,5 +1,5 @@
 // { dg-options "-Wno-deprecated" }
-import core.stdc.stdio;
+import core.stdc.stdio : fprintf, stderr;
 
 // Make sure basic stuff works with future Throwable.message
 class NoMessage : Throwable
index 70762ff227c597aeec8265399cbff8b4cb6d1ed3..ed237c2f7e1961d60e99897022988d6375270ba9 100644 (file)
@@ -7,7 +7,7 @@ void main()
     }
     catch (Exception e)
     {
-        import core.stdc.stdio;
+        import core.stdc.stdio : printf;
         auto str = e.toString();
         printf("%.*s\n", cast(int)str.length, str.ptr);
     }
index 3ff45e55c87a0ec1995f22f5f1bba9ba526d5a2a..384bb2a7381d062f01a0b0ab5558f4714ec03eee 100644 (file)
@@ -30,7 +30,7 @@ void main() {
     HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH x;
     x.tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt(1);
     } catch (Exception e) {
-        import core.stdc.stdio;
+        import core.stdc.stdio : printf;
         auto str = e.toString();
         printf("%.*s\n", cast(int)str.length, str.ptr);
     }
index 37a49b458ad9c1d972c43ff9e304ac717ba0b202..7ad4c2a77f348ce12c3f2651d894c2d72b914475 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-shouldfail "static_dtor_exception" }
 // { dg-output "object.Exception@.*: static_dtor_exception" }
 // https://issues.dlang.org/show_bug.cgi?id=16594
-import core.stdc.stdio;
+import core.stdc.stdio : fprintf, stderr;
 
 shared static ~this()
 {
index 9c18dc296f0b0e165b1701a90a83fa736cddda4b..f85d9f186b9f1edce05bb0784f01335af8fd89ae 100644 (file)
@@ -1,5 +1,5 @@
 import core.memory;
-import core.stdc.stdio;
+import core.stdc.stdio : printf;
 import core.sys.posix.sys.wait;
 import core.sys.posix.unistd;
 
index 9bcaf3f4faad0de69227aabcb664d1d9b8f8214e..c22dbdb14eb00cd8e89204841a2d122b540840ec 100644 (file)
@@ -7,7 +7,7 @@
 module testgc;
 
 import core.memory;
-import core.stdc.stdio;
+import core.stdc.stdio : printf;
 
 class C
 {
index 59c3b4ab597b95e826e46861ab2130b05786a486..e5273a7e5bcd4d3127ea80e12d9f01c50826b377 100644 (file)
@@ -1,5 +1,4 @@
 // https://issues.dlang.org/show_bug.cgi?id=20438
-import core.stdc.stdio;
 import core.memory;
 
 void main()
index 0ad2443c826ea2cfebc9223c893bd9a9cfd7c246..2bbf3133e2d0ede0b3b51987371f680a1573d802 100644 (file)
@@ -171,7 +171,7 @@ void issue19568()
 
         ~this() @nogc nothrow
         {
-            import core.stdc.stdio;
+            import core.stdc.stdio : puts;
             if (mptr) puts("impure");
         }
 
@@ -185,7 +185,7 @@ void issue19568()
 
         ~this() @nogc nothrow
         {
-            import core.stdc.stdio;
+            import core.stdc.stdio : puts;
             if (fd != -1) puts("impure");
         }
 
index bcbd84c844f16b3aded9ead6b1a771dba6b3c1ad..b85aa889da94b9f928956f474701b707f6326229 100644 (file)
@@ -1,6 +1,6 @@
-import core.gc.registry;
 import core.gc.gcinterface;
-import core.stdc.stdlib;
+import core.gc.registry;
+import core.stdc.stdlib : calloc, malloc, realloc;
 
 static import core.memory;
 
index a40cd5ebe0431f970565445c7e7129f2c6b15162..b7700429bd406791cf9bd5040a0ea0c1387f1a02 100644 (file)
@@ -1,7 +1,6 @@
 // Bugzilla 11309 - std.concurrency: OwnerTerminated message doesn't work
 // We need to assure that the thread dtors of parent threads run before the thread dtors of the child threads.
 import core.thread, core.sync.semaphore;
-import core.stdc.stdio;
 
 __gshared Semaphore sem;
 
index 9c98a3fa13d172df008d6edc5d1120461c824f78..a59fc76dbb986b306b9580e3fee67a88177666b2 100644 (file)
@@ -1,5 +1,6 @@
-import core.sys.posix.pthread;
 import core.memory;
+import core.sys.posix.pthread : pthread_create, pthread_join;
+import core.sys.posix.sys.types : pthread_t;
 import core.thread;
 
 extern (C) void  rt_moduleTlsCtor();
index dbdd0f9d08d4e3cd6d9c8701c9aa3fe8c1311ebd..e4f61fac86f22daf8639e6d12adb3b446a17470d 100644 (file)
@@ -1,8 +1,8 @@
 // { dg-options "-O0" }
 // { dg-shouldfail "segv or bus error" }
 import core.thread;
-import core.sys.posix.signal;
-import core.sys.posix.sys.mman;
+import core.sys.posix.signal : MINSIGSTKSZ;
+import core.sys.posix.sys.mman : MAP_ANON, MAP_PRIVATE, mmap, PROT_READ, PROT_WRITE;
 
 version (LDC) import ldc.attributes;
 else struct optStrategy { string a; }
index 1bd3f26cffc925b6255f90f126120a646661fbac..b0807ec6ff15993b8e38dbcebc81050814c8bbb8 100644 (file)
@@ -11,7 +11,7 @@ class C
 {
     ~this()
     {
-        import core.stdc.stdlib;
+        import core.stdc.stdlib : abort;
         abort();    // this gets triggered although the instance always stays referenced
     }
 }
index dbd93213bfec19b4d5e5e294ca9ec18b154b1821..7b76f22fa920f25a5a93eec6555c7cec76973041 100644 (file)
@@ -1,6 +1,6 @@
 module core.thread.test; // needs access to getStackTop()/getStackBottom()
 
-import core.stdc.stdio;
+import core.stdc.stdio : printf;
 import core.thread;
 
 ubyte[16384] data;
index f5a04350d9c80f826714c9e444d130f7abe3fc5e..2beeb78ad82dcf1053c34db4bf9af23ecda5d659 100644 (file)
@@ -16,6 +16,6 @@ shared static this()
 
 void main()
 {
-    import core.stdc.stdio;
+    import core.stdc.stdio : fprintf, stderr;
     fprintf(stderr, "main\n");
 }