public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/28899] New: FAIL: nptl/tst-cleanupx4
@ 2022-02-16 20:24 danglin at gcc dot gnu.org
  2022-02-17  0:35 ` [Bug nptl/28899] " danglin at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: danglin at gcc dot gnu.org @ 2022-02-16 20:24 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28899

            Bug ID: 28899
           Summary: FAIL: nptl/tst-cleanupx4
           Product: glibc
           Version: 2.36
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
          Assignee: unassigned at sourceware dot org
          Reporter: danglin at gcc dot gnu.org
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---
              Host: hppa*-*-linux*
            Target: hppa*-*-linux*
             Build: hppa*-*-linux*

Created attachment 13984
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13984&action=edit
Preprocessed source

FAIL: nptl/tst-cleanupx4

dave@atlas:~/gnu/glibc/objdir/nptl$ cat tst-cleanupx4.out
test 0
clh (2)
clh (1)
clh (3)
global = 12, expected 15
test 1
clh (4)
clh (6)
clh (1)
clh (5)
global = 160, expected 276
test 2
clh (8)
clh (1)
clh (7)
global = 70, expected 120
test 3
clh (2)
clh (10)
clh (1)
clh (9)
global = 288, expected 460

I modified the test to add the noninline attribute to clh() because
I noticed it was inlined into fn0() and fn2().  Still the test is
miscompiled:

(gdb) r
Starting program: /home/dave/gnu/glibc/objdir/elf/ld.so.1 --library-path
/home/dave/gnu/glibc/objdir:/home/dave/gnu/glibc/objdir/math:/home/dave/gnu/glibc/objdir/elf:/home/dave/gnu/glibc/objdir/dlfcn:/home/dave/gnu/glibc/objdir/nss:/home/dave/gnu/glibc/objdir/nis:/home/dave/gnu/glibc/objdir/rt:/home/dave/gnu/glibc/objdir/resolv:/home/dave/gnu/glibc/objdir/mathvec:/home/dave/gnu/glibc/objdir/support:/home/dave/gnu/glibc/objdir/crypt:/home/dave/gnu/glibc/objdir/nptl
/home/dave/gnu/glibc/objdir/nptl/tst-cleanupx4
warning: Unable to find libthread_db matching inferior's thread library, thread
debugging will not be available.
[Attaching after process 30863 fork to child process 30866]
[New inferior 2 (process 30866)]
[Detaching after fork from parent process 30863]
[Inferior 1 (process 30863) detached]
warning: Unable to find libthread_db matching inferior's thread library, thread
debugging will not be available.
test 0
[New LWP 30867]

Thread 2.2 "ld.so.1" received signal SIG32, Real-time event 32.
[Switching to LWP 30867]
0xf900156c in ?? () from /home/dave/gnu/glibc/objdir/libc.so.6
(gdb) c
Continuing.

Thread 2.2 "ld.so.1" hit Breakpoint 1, clh (arg=0x2) at tst-cleanup4.c:47
47        int val = (long int) arg;
(gdb) bt
#0  clh (arg=0x2) at tst-cleanup4.c:47
#1  0xf8f553c0 in unwind_stop (version=<optimized out>,
    actions=<optimized out>, exc_class=<optimized out>,
    exc_obj=<optimized out>, context=<optimized out>,
    stop_parameter=<optimized out>) at unwind.c:80
#2  0xf9196c70 in ?? () from /lib/hppa-linux-gnu/libgcc_s.so.4
#3  0xf9197300 in _Unwind_ForcedUnwind ()
   from /lib/hppa-linux-gnu/libgcc_s.so.4
#4  0xf8ee319c in _Unwind_ForcedUnwind (exc=0x0, stop=0x0,
    stop_argument=0xf8eb4000) at ../sysdeps/generic/unwind-resume.c:51
#5  0xf8f554f0 in __GI___pthread_unwind (buf=<optimized out>) at unwind.c:130
#6  0xf8f46c78 in __do_cancel () at ../sysdeps/nptl/pthreadP.h:280
#7  sigcancel_handler (sig=32, si=0x0, ctx=<optimized out>)
    at pthread_cancel.c:56
#8  sigcancel_handler (sig=<optimized out>, si=0x0, ctx=<optimized out>)
    at pthread_cancel.c:32
#9  <signal handler called>
#10 0xf8fbfd60 in __GI___libc_read (nbytes=1, buf=0xf86b32c8, fd=3)
    at ../sysdeps/unix/sysv/linux/read.c:26
#11 __GI___libc_read (fd=3, buf=0xf86b32c8, nbytes=1)
    at ../sysdeps/unix/sysv/linux/read.c:24
#12 0x000117a0 in fn_read () at tst-cleanup4.c:67
#13 0x000117dc in fn0 () at tst-cleanup4.c:76
--Type <RET> for more, q to quit, c to continue without paging--
#14 0x0001182c in fn1 () at tst-cleanup4.c:89
#15 0x00011854 in fn2 () at tst-cleanup4.c:100
#16 0x000118ec in tf (a=<optimized out>) at tst-cleanup4.c:112
#17 0xf8f49464 in start_thread (arg=0xf8eb33c0) at pthread_create.c:442
#18 0xf8fd907c in clone () at ../sysdeps/unix/sysv/linux/hppa/clone.S:151
Backtrace stopped: Cannot access memory at address 0xf86b2fec
(gdb) disass fn0
Dump of assembler code for function fn0:
   0x000117cc <+0>:     stw rp,-14(sp)
   0x000117d0 <+4>:     stw,ma r3,40(sp)
   0x000117d4 <+8>:     b,l 0x11768 <fn_read>,rp
   0x000117d8 <+12>:    nop
   0x000117dc <+16>:    ldi 1,r26
   0x000117e0 <+20>:    ldw -54(sp),rp
   0x000117e4 <+24>:    b,l 0x1170c <clh>,r0
   0x000117e8 <+28>:    ldw,mb -40(sp),r3
   0x000117ec <+32>:    ldi 1,r26
   0x000117f0 <+36>:    b,l 0x1170c <clh>,rp
   0x000117f4 <+40>:    copy r20,r3
   0x000117f8 <+44>:    b,l 0x110b4,rp
   0x000117fc <+48>:    copy r3,r26
   0x00011800 <+52>:    nop
End of assembler dump.

The cleanup handler in fn0 is not registered before fn_read is called.
As a result, the cleanup registered using _pthread_cleanup_push in fn1
is on the top of the stack.

Attached .i file for test.  This is code for fn0:
__attribute__((noinline)) void
fn0 (void)
{
  do { struct __pthread_cleanup_frame __clframe __attribute__ ((__cleanup__
(__pthread_cleanup_routine))) = { .__cancel_routine = (clh), .__cancel_arg =
((void *) 1l), .__do_it = 1 };;

  fn_read ();

  __clframe.__do_it = (1); } while (0);
}

Not sure but this might be a compiler bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-28 15:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 20:24 [Bug nptl/28899] New: FAIL: nptl/tst-cleanupx4 danglin at gcc dot gnu.org
2022-02-17  0:35 ` [Bug nptl/28899] " danglin at gcc dot gnu.org
2022-02-24 17:57 ` danglin at gcc dot gnu.org
2022-02-28 15:59 ` danglin at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).