public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/30132] New: [gdb/testsuite] FAIL: gdb.arch/amd64-disp-step-avx.exp: continue until exit at amd64-disp-step-avx
@ 2023-02-17 10:59 vries at gcc dot gnu.org
  2023-02-17 14:33 ` [Bug testsuite/30132] " cvs-commit at gcc dot gnu.org
  2023-02-17 14:34 ` vries at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: vries at gcc dot gnu.org @ 2023-02-17 10:59 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30132
           Summary: [gdb/testsuite] FAIL:
                    gdb.arch/amd64-disp-step-avx.exp: continue until exit
                    at amd64-disp-step-avx
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: testsuite
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

On SLE-11, with glibc 2.11.3, I run into:
...
(gdb) PASS: gdb.arch/amd64-disp-step-avx.exp: vex3: var128 has expected value
after
continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0x0000000000400283 in _exit (status=0) at
../sysdeps/unix/sysv/linux/_exit.c:33^M
33      ../sysdeps/unix/sysv/linux/_exit.c: No such file or directory.^M
(gdb) FAIL: gdb.arch/amd64-disp-step-avx.exp: continue until exit at
amd64-disp-step-avx
...

This not related to gdb, just by running the exec we get the same result.

The problem is that the test-case:
- calls glibc's _exit
- uses -nostartfiles, putting the burden for any necessary initialization for
  calling glibc's _exit on the test-case itself
- uses static, meaning there's no additional initialization by say
  dynamic linker or libc.so initializer

So, when we get to the second insn here:
...
000000000040acb0 <_exit>:
  40acb0:       48 63 d7                movslq %edi,%rdx
  40acb3:       64 4c 8b 14 25 00 00    mov    %fs:0x0,%r10
...
there's insufficient initialization done, and we run into the segfault.

Adding this in start:
...
         .rept 200
         nop
+        call __pthread_initialize_minimal
         .endr
...
is sufficient to fix it.  But that doesn't compile on my development system
with glibc 2.31.

We could just not run through to exit.

Or do the syscall in the test-case.

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

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

* [Bug testsuite/30132] [gdb/testsuite] FAIL: gdb.arch/amd64-disp-step-avx.exp: continue until exit at amd64-disp-step-avx
  2023-02-17 10:59 [Bug testsuite/30132] New: [gdb/testsuite] FAIL: gdb.arch/amd64-disp-step-avx.exp: continue until exit at amd64-disp-step-avx vries at gcc dot gnu.org
@ 2023-02-17 14:33 ` cvs-commit at gcc dot gnu.org
  2023-02-17 14:34 ` vries at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-17 14:33 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ab3fdfe6e4805eff45ec4d701d0cd6511d9c3690

commit ab3fdfe6e4805eff45ec4d701d0cd6511d9c3690
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Feb 17 15:33:18 2023 +0100

    [gdb/testsuite] Simplify gdb.arch/amd64-disp-step-avx.exp

    On SLE-11, with glibc 2.11.3, I run into:
    ...
    (gdb) PASS: gdb.arch/amd64-disp-step-avx.exp: vex3: \
      var128 has expected value after
    continue^M
    Continuing.^M
    ^M
    Program received signal SIGSEGV, Segmentation fault.^M
    0x0000000000400283 in _exit (status=0) at \
      ../sysdeps/unix/sysv/linux/_exit.c:33^M
    33      ../sysdeps/unix/sysv/linux/_exit.c: No such file or directory.^M
    (gdb) FAIL: gdb.arch/amd64-disp-step-avx.exp: \
      continue until exit at amd64-disp-step-avx
    ...

    This is not related to gdb, we get the same result by just running the
exec.

    The problem is that the test-case:
    - calls glibc's _exit, and
    - uses -nostartfiles -static, putting the burden for any necessary
      initialization for calling glibc's _exit on the test-case itself.

    So, when we get to the second insn in _exit:
    ...
    000000000040acb0 <_exit>:
      40acb0:       48 63 d7                movslq %edi,%rdx
      40acb3:       64 4c 8b 14 25 00 00    mov    %fs:0x0,%r10
    ...
    no glibc-related initialization is done, and we run into the segfault.

    Adding this (borrowed from __libc_start_main) in _start in the .S file is
    sufficient to fix it:
    ...
             .rept 200
             nop
    +        call __pthread_initialize_minimal
             .endr
    ...
    But that already doesn't compile with say glibc 2.31, and regardless I
think
    this sort of fix is too fragile.

    We could of course fix this by simply not running to exit.  But ideally
we'd
    have an exec that doesn't segfault when you just run it.

    Alternatively, we could hand-code an _exit syscall and bypass glibc
    all together.  But I'd rather fix this in a way that simplifies the
test-case.

    Taking a step back, the -nostartfiles -static was added to address that the
    xmm registers were not zero at main (which AFAICT is a valid thing to
happen).

    [ The change itself silently broke the test-case, needing further fixing by
    commit 40310f30a51 ("gdb: make gdb.arch/amd64-disp-step-avx.exp actually
test
    displaced stepping"). ]

    Instead, simplify things by reverting to the original situation:
    - no -nostartfiles -static compilation flags,
    - no _start in the .S file,
    - use exit instead of _exit in the .S file,
    and fix the original problem by setting the xmm registers to zero rather
than
    checking that they're zero.

    Now that we're no longer forcing -static, add nopie to the flags to prevent
    compilation failure with target board unix/-fPIE/-pie.

    Tested on x86_64-linux.

    PR testsuite/30132
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30132

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

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

* [Bug testsuite/30132] [gdb/testsuite] FAIL: gdb.arch/amd64-disp-step-avx.exp: continue until exit at amd64-disp-step-avx
  2023-02-17 10:59 [Bug testsuite/30132] New: [gdb/testsuite] FAIL: gdb.arch/amd64-disp-step-avx.exp: continue until exit at amd64-disp-step-avx vries at gcc dot gnu.org
  2023-02-17 14:33 ` [Bug testsuite/30132] " cvs-commit at gcc dot gnu.org
@ 2023-02-17 14:34 ` vries at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: vries at gcc dot gnu.org @ 2023-02-17 14:34 UTC (permalink / raw)
  To: gdb-prs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |14.1
         Resolution|---                         |FIXED

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed.

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

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

end of thread, other threads:[~2023-02-17 14:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 10:59 [Bug testsuite/30132] New: [gdb/testsuite] FAIL: gdb.arch/amd64-disp-step-avx.exp: continue until exit at amd64-disp-step-avx vries at gcc dot gnu.org
2023-02-17 14:33 ` [Bug testsuite/30132] " cvs-commit at gcc dot gnu.org
2023-02-17 14:34 ` vries 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).