]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Test FPU preservation on double-signal delivery
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Tue, 3 Feb 2026 21:54:35 +0000 (21:54 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Wed, 4 Feb 2026 07:15:57 +0000 (08:15 +0100)
This test was fixed by 826484111a ("hurd: handling pending signals could
result in corruption of FPU state.")

hurd/test-sig-xstate.c

index 8ddfbebcd522e24b62fed26a0d918c7cc016e799..9e7c77b56037d30ab6f1536df52a51df5c623104 100644 (file)
@@ -43,6 +43,7 @@
 
 static volatile atomic_bool startflag = ATOMIC_VAR_INIT (false);
 static volatile atomic_bool loopflag = ATOMIC_VAR_INIT (true);
+static volatile bool doublesig = false;
 
 void handler (int signum, siginfo_t *info, void *context)
 {
@@ -53,7 +54,13 @@ void handler (int signum, siginfo_t *info, void *context)
   SET_MMXSTATE (mmxbuf3);
   SET_XSTATE (xbuf3);
   printf ("signal %d setting a different CPU state\n", signum);
-  atomic_store_explicit (&loopflag, false, memory_order_release);
+  if (doublesig)
+    {
+      doublesig = false;
+      TEST_COMPARE (kill (getpid (), SIGUSR1), 0);
+    }
+  else
+    atomic_store_explicit (&loopflag, false, memory_order_release);
 }
 
 /* Helper thread to send a signal to the main thread  */
@@ -101,6 +108,28 @@ static int do_test (void)
   TEST_COMPARE_BLOB (xbuf1, sizeof (xbuf1), xbuf2, sizeof (xbuf2));
 
   xpthread_join (thsender);
+
+  /* Now retry with double signalling.  */
+  doublesig = true;
+  atomic_store_explicit (&startflag, false, memory_order_relaxed);
+  atomic_store_explicit (&loopflag, true, memory_order_relaxed);
+
+  thsender = xpthread_create (NULL, signal_sender, NULL);
+
+  SET_MMXSTATE (mmxbuf1);
+  SET_XSTATE (xbuf1);
+
+  atomic_store_explicit (&startflag, true, memory_order_release);
+  while (atomic_load_explicit (&loopflag, memory_order_acquire))
+    ;
+
+  GET_MMXSTATE (mmxbuf2);
+  GET_XSTATE (xbuf2);
+  TEST_COMPARE_BLOB (mmxbuf1, sizeof (mmxbuf1), mmxbuf2, sizeof (mmxbuf2));
+  TEST_COMPARE_BLOB (xbuf1, sizeof (xbuf1), xbuf2, sizeof (xbuf2));
+
+  xpthread_join (thsender);
+
   return EXIT_SUCCESS;
 }