https://gcc.gnu.org/g:b3b54f9c9a74909a41ea566c2135c9e01121994c

commit r15-8269-gb3b54f9c9a74909a41ea566c2135c9e01121994c
Author: Iain Buclaw <ibuc...@gdcproject.org>
Date:   Sat Mar 15 16:32:48 2025 +0100

    libphobos: Merge changes in upstream druntime testsuite
    
    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.

Diff:
---
 libphobos/libdruntime/MERGE                        |  2 +-
 libphobos/testsuite/libphobos.aa/test_aa.d         | 44 +++++++++++++++++++++-
 libphobos/testsuite/libphobos.betterc/test19933.d  |  2 +-
 libphobos/testsuite/libphobos.config/test22523.d   |  2 +-
 .../testsuite/libphobos.exceptions/assert_fail.d   |  8 ++++
 libphobos/testsuite/libphobos.exceptions/chain.d   |  2 +-
 .../libphobos.exceptions/future_message.d          |  2 +-
 .../testsuite/libphobos.exceptions/line_trace.d    |  2 +-
 .../libphobos.exceptions/long_backtrace_trunc.d    |  2 +-
 .../testsuite/libphobos.exceptions/static_dtor.d   |  2 +-
 libphobos/testsuite/libphobos.gc/forkgc.d          |  2 +-
 libphobos/testsuite/libphobos.gc/precisegc.d       |  2 +-
 libphobos/testsuite/libphobos.gc/recoverfree.d     |  1 -
 libphobos/testsuite/libphobos.hash/test_hash.d     |  4 +-
 .../testsuite/libphobos.init_fini/custom_gc.d      |  4 +-
 .../testsuite/libphobos.init_fini/thread_join.d    |  1 -
 .../testsuite/libphobos.thread/external_threads.d  |  3 +-
 .../testsuite/libphobos.thread/fiber_guard_page.d  |  4 +-
 .../testsuite/libphobos.thread/tlsgc_sections.d    |  2 +-
 libphobos/testsuite/libphobos.thread/tlsstack.d    |  2 +-
 .../testsuite/libphobos.unittest/customhandler.d   |  2 +-
 21 files changed, 71 insertions(+), 24 deletions(-)

diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 070d9fec28b9..18c9d1190ced 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -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.
diff --git a/libphobos/testsuite/libphobos.aa/test_aa.d 
b/libphobos/testsuite/libphobos.aa/test_aa.d
index 11ad2f90ff1d..5c3ba05d83d3 100644
--- a/libphobos/testsuite/libphobos.aa/test_aa.d
+++ b/libphobos/testsuite/libphobos.aa/test_aa.d
@@ -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.
+}
diff --git a/libphobos/testsuite/libphobos.betterc/test19933.d 
b/libphobos/testsuite/libphobos.betterc/test19933.d
index a0faadd21120..d5c9eacf0df0 100644
--- a/libphobos/testsuite/libphobos.betterc/test19933.d
+++ b/libphobos/testsuite/libphobos.betterc/test19933.d
@@ -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()
 {
diff --git a/libphobos/testsuite/libphobos.config/test22523.d 
b/libphobos/testsuite/libphobos.config/test22523.d
index f3086963f2e9..680f573ce700 100644
--- a/libphobos/testsuite/libphobos.config/test22523.d
+++ b/libphobos/testsuite/libphobos.config/test22523.d
@@ -1,6 +1,6 @@
 // https://issues.dlang.org/show_bug.cgi?id=22523
 
-import core.stdc.stdio;
+import core.stdc.stdio : puts;
 
 int main()
 {
diff --git a/libphobos/testsuite/libphobos.exceptions/assert_fail.d 
b/libphobos/testsuite/libphobos.exceptions/assert_fail.d
index 352ccca3901d..ee5caf6e198f 100644
--- a/libphobos/testsuite/libphobos.exceptions/assert_fail.d
+++ b/libphobos/testsuite/libphobos.exceptions/assert_fail.d
@@ -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);
diff --git a/libphobos/testsuite/libphobos.exceptions/chain.d 
b/libphobos/testsuite/libphobos.exceptions/chain.d
index 0305707fc62a..d860ff072e0f 100644
--- a/libphobos/testsuite/libphobos.exceptions/chain.d
+++ b/libphobos/testsuite/libphobos.exceptions/chain.d
@@ -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
 {
diff --git a/libphobos/testsuite/libphobos.exceptions/future_message.d 
b/libphobos/testsuite/libphobos.exceptions/future_message.d
index 61b103482872..65a6b5633cf7 100644
--- a/libphobos/testsuite/libphobos.exceptions/future_message.d
+++ b/libphobos/testsuite/libphobos.exceptions/future_message.d
@@ -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
diff --git a/libphobos/testsuite/libphobos.exceptions/line_trace.d 
b/libphobos/testsuite/libphobos.exceptions/line_trace.d
index 70762ff227c5..ed237c2f7e19 100644
--- a/libphobos/testsuite/libphobos.exceptions/line_trace.d
+++ b/libphobos/testsuite/libphobos.exceptions/line_trace.d
@@ -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);
     }
diff --git a/libphobos/testsuite/libphobos.exceptions/long_backtrace_trunc.d 
b/libphobos/testsuite/libphobos.exceptions/long_backtrace_trunc.d
index 3ff45e55c87a..384bb2a7381d 100644
--- a/libphobos/testsuite/libphobos.exceptions/long_backtrace_trunc.d
+++ b/libphobos/testsuite/libphobos.exceptions/long_backtrace_trunc.d
@@ -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);
     }
diff --git a/libphobos/testsuite/libphobos.exceptions/static_dtor.d 
b/libphobos/testsuite/libphobos.exceptions/static_dtor.d
index 37a49b458ad9..7ad4c2a77f34 100644
--- a/libphobos/testsuite/libphobos.exceptions/static_dtor.d
+++ b/libphobos/testsuite/libphobos.exceptions/static_dtor.d
@@ -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()
 {
diff --git a/libphobos/testsuite/libphobos.gc/forkgc.d 
b/libphobos/testsuite/libphobos.gc/forkgc.d
index 9c18dc296f0b..f85d9f186b9f 100644
--- a/libphobos/testsuite/libphobos.gc/forkgc.d
+++ b/libphobos/testsuite/libphobos.gc/forkgc.d
@@ -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;
 
diff --git a/libphobos/testsuite/libphobos.gc/precisegc.d 
b/libphobos/testsuite/libphobos.gc/precisegc.d
index 9bcaf3f4faad..c22dbdb14eb0 100644
--- a/libphobos/testsuite/libphobos.gc/precisegc.d
+++ b/libphobos/testsuite/libphobos.gc/precisegc.d
@@ -7,7 +7,7 @@
 module testgc;
 
 import core.memory;
-import core.stdc.stdio;
+import core.stdc.stdio : printf;
 
 class C
 {
diff --git a/libphobos/testsuite/libphobos.gc/recoverfree.d 
b/libphobos/testsuite/libphobos.gc/recoverfree.d
index 59c3b4ab597b..e5273a7e5bcd 100644
--- a/libphobos/testsuite/libphobos.gc/recoverfree.d
+++ b/libphobos/testsuite/libphobos.gc/recoverfree.d
@@ -1,5 +1,4 @@
 // https://issues.dlang.org/show_bug.cgi?id=20438
-import core.stdc.stdio;
 import core.memory;
 
 void main()
diff --git a/libphobos/testsuite/libphobos.hash/test_hash.d 
b/libphobos/testsuite/libphobos.hash/test_hash.d
index 0ad2443c826e..2bbf3133e2d0 100644
--- a/libphobos/testsuite/libphobos.hash/test_hash.d
+++ b/libphobos/testsuite/libphobos.hash/test_hash.d
@@ -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");
         }
 
diff --git a/libphobos/testsuite/libphobos.init_fini/custom_gc.d 
b/libphobos/testsuite/libphobos.init_fini/custom_gc.d
index bcbd84c844f1..b85aa889da94 100644
--- a/libphobos/testsuite/libphobos.init_fini/custom_gc.d
+++ b/libphobos/testsuite/libphobos.init_fini/custom_gc.d
@@ -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;
 
diff --git a/libphobos/testsuite/libphobos.init_fini/thread_join.d 
b/libphobos/testsuite/libphobos.init_fini/thread_join.d
index a40cd5ebe043..b7700429bd40 100644
--- a/libphobos/testsuite/libphobos.init_fini/thread_join.d
+++ b/libphobos/testsuite/libphobos.init_fini/thread_join.d
@@ -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;
 
diff --git a/libphobos/testsuite/libphobos.thread/external_threads.d 
b/libphobos/testsuite/libphobos.thread/external_threads.d
index 9c98a3fa13d1..a59fc76dbb98 100644
--- a/libphobos/testsuite/libphobos.thread/external_threads.d
+++ b/libphobos/testsuite/libphobos.thread/external_threads.d
@@ -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();
diff --git a/libphobos/testsuite/libphobos.thread/fiber_guard_page.d 
b/libphobos/testsuite/libphobos.thread/fiber_guard_page.d
index dbdd0f9d08d4..e4f61fac86f2 100644
--- a/libphobos/testsuite/libphobos.thread/fiber_guard_page.d
+++ b/libphobos/testsuite/libphobos.thread/fiber_guard_page.d
@@ -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; }
diff --git a/libphobos/testsuite/libphobos.thread/tlsgc_sections.d 
b/libphobos/testsuite/libphobos.thread/tlsgc_sections.d
index 1bd3f26cffc9..b0807ec6ff15 100644
--- a/libphobos/testsuite/libphobos.thread/tlsgc_sections.d
+++ b/libphobos/testsuite/libphobos.thread/tlsgc_sections.d
@@ -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
     }
 }
diff --git a/libphobos/testsuite/libphobos.thread/tlsstack.d 
b/libphobos/testsuite/libphobos.thread/tlsstack.d
index dbd93213bfec..7b76f22fa920 100644
--- a/libphobos/testsuite/libphobos.thread/tlsstack.d
+++ b/libphobos/testsuite/libphobos.thread/tlsstack.d
@@ -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;
diff --git a/libphobos/testsuite/libphobos.unittest/customhandler.d 
b/libphobos/testsuite/libphobos.unittest/customhandler.d
index f5a04350d9c8..2beeb78ad82d 100644
--- a/libphobos/testsuite/libphobos.unittest/customhandler.d
+++ b/libphobos/testsuite/libphobos.unittest/customhandler.d
@@ -16,6 +16,6 @@ shared static this()
 
 void main()
 {
-    import core.stdc.stdio;
+    import core.stdc.stdio : fprintf, stderr;
     fprintf(stderr, "main\n");
 }

Reply via email to