SIGBUS failure for misc/tst-bz21269 on i386

Message ID 23e0f059-1fd0-8b95-ce35-99eba8a96a30@redhat.com
State Committed
Headers

Commit Message

Florian Weimer March 28, 2018, 8:01 a.m. UTC
  On 03/27/2018 11:47 PM, Aurelien Jarno wrote:
> Here is the coredump that I can get:
> 
>    Thread 1 "tst-bz21269" received signal SIGBUS, Bus error.
>    0x565564a0 in do_test () at ../sysdeps/unix/sysv/linux/i386/tst-bz21269.c:217
>    217           while (atomic_load (&ftx) != 0)
>    (gdb) bt
>    #0  0x565564a0 in do_test () at ../sysdeps/unix/sysv/linux/i386/tst-bz21269.c:217
>    #1  0x56556bc2 in support_test_main (argc=<optimized out>, argv=0xffffd518, config=0xffffd424) at support_test_main.c:321
>    #2  0x56556061 in main (argc=2, argv=0xffffd514) at ../support/test-driver.c:164
>    (gdb) print &ftx
>    $1 = (atomic_uint *) 0x5655a0e0 <ftx>
>    (gdb) print ftx
>    $2 = 0

Ahh.  I see.

       /* Fire up thread modify_ldt call.  */
       atomic_store (&ftx, 2);

       while (atomic_load (&ftx) != 0)
	;

       /* On success, modify_ldt will segfault us synchronously and we 
will escape via siglongjmp.  */
       support_record_failure ();

But:

   xsethandler (SIGSEGV, sigsegv_handler, 0);
   /* 32-bit kernels send SIGILL instead of SIGSEGV on IRET faults.  */
   xsethandler (SIGILL, sigsegv_handler, 0);

So some kernels apparently use SIGBUS instead, and the crash actually 
shows the test succeeded.

Would you please try the attached patch?

Thanks,
Florian
  

Comments

Aurelien Jarno March 28, 2018, 5:36 p.m. UTC | #1
On 2018-03-28 10:01, Florian Weimer wrote:
> On 03/27/2018 11:47 PM, Aurelien Jarno wrote:
> > Here is the coredump that I can get:
> > 
> >    Thread 1 "tst-bz21269" received signal SIGBUS, Bus error.
> >    0x565564a0 in do_test () at ../sysdeps/unix/sysv/linux/i386/tst-bz21269.c:217
> >    217           while (atomic_load (&ftx) != 0)
> >    (gdb) bt
> >    #0  0x565564a0 in do_test () at ../sysdeps/unix/sysv/linux/i386/tst-bz21269.c:217
> >    #1  0x56556bc2 in support_test_main (argc=<optimized out>, argv=0xffffd518, config=0xffffd424) at support_test_main.c:321
> >    #2  0x56556061 in main (argc=2, argv=0xffffd514) at ../support/test-driver.c:164
> >    (gdb) print &ftx
> >    $1 = (atomic_uint *) 0x5655a0e0 <ftx>
> >    (gdb) print ftx
> >    $2 = 0
> 
> Ahh.  I see.
> 
>       /* Fire up thread modify_ldt call.  */
>       atomic_store (&ftx, 2);
> 
>       while (atomic_load (&ftx) != 0)
> 	;
> 
>       /* On success, modify_ldt will segfault us synchronously and we will
> escape via siglongjmp.  */
>       support_record_failure ();
> 
> But:
> 
>   xsethandler (SIGSEGV, sigsegv_handler, 0);
>   /* 32-bit kernels send SIGILL instead of SIGSEGV on IRET faults.  */
>   xsethandler (SIGILL, sigsegv_handler, 0);
> 
> So some kernels apparently use SIGBUS instead, and the crash actually shows
> the test succeeded.
> 
> Would you please try the attached patch?

I confirm that this patch works. It returns no error with the fixed
libc, and a segmentation one with the previous one without the bz21269
fix.

Aurelien
  
Florian Weimer March 28, 2018, 5:47 p.m. UTC | #2
On 03/28/2018 07:36 PM, Aurelien Jarno wrote:
> I confirm that this patch works. It returns no error with the fixed
> libc, and a segmentation one with the previous one without the bz21269
> fix.

I reviewed the bug again, and I don't think it will interfere with the 
test objective, so I'm going to commit this soon unless someone objects.

Thanks,
Florian
  

Patch

Subject: [PATCH] Linux i386: tst-bz21269 triggers SIGBUS on some kernels
To: libc-alpha@sourceware.org

In addition to SIGSEGV and SIGILL, SIGBUS is also a possible signal
generated by the kernel.

2018-03-28  Florian Weimer  <fweimer@redhat.com>

	* sysdeps/unix/sysv/linux/i386/tst-bz21269.c (do_test): Also
	capture SIGBUS.

diff --git a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
index 353e36507d..6ee3fc62be 100644
--- a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
+++ b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
@@ -177,6 +177,8 @@  do_test (void)
   xsethandler (SIGSEGV, sigsegv_handler, 0);
   /* 32-bit kernels send SIGILL instead of SIGSEGV on IRET faults.  */
   xsethandler (SIGILL, sigsegv_handler, 0);
+  /* Some kernels send SIGBUS instead.  */
+  xsethandler (SIGBUS, sigsegv_handler, 0);
 
   thread = xpthread_create (0, threadproc, 0);