public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/27613] New: finish from sigreturn trampoline sometimes doesn't stop
@ 2021-03-19 15:53 ismith at undo dot io
  2021-03-19 15:56 ` [Bug gdb/27613] " ismith at undo dot io
  0 siblings, 1 reply; 2+ messages in thread
From: ismith at undo dot io @ 2021-03-19 15:53 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 27613
           Summary: finish from sigreturn trampoline sometimes doesn't
                    stop
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: ismith at undo dot io
  Target Milestone: ---

It seems that if a signal is delivered when the program is about to execute a
'ret' instruction in an assembly function, using 'finish' in the signal handler
goes to the trampoline (fine) but 'finish' from there doesn't stop until the
next breakpoint (or end of program).

Test files:

asm.S

 .global asm_func
asm_func:
    mov $0xdeadbeefdeadbeef, %rdi
    ret



test.c

#include <assert.h>
#include <inttypes.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>

static void
sig_handler(int sig)
{
    (void)sig;
}

void asm_func(void);

int
main(void)
{
    struct sigaction act;
    act.sa_sigaction = (void *)sig_handler;
    act.sa_flags = 0;
    sigemptyset(&act.sa_mask);
    int r = sigaction(SIGVTALRM, &act, NULL);
    assert(r == 0);

    asm_func();
    return 0;
}

Compiled with:
gcc (Ubuntu 10.1.0-2ubuntu1~18.04) 10.1.0

gcc -g asm.S test.c -o test

$ gdb -q ./test
Reading symbols from ./test...done.
(gdb) b asm_func
Breakpoint 1 at 0x7d8: file asm.S, line 3.
(gdb) r
Starting program: /home/ismith/work/overnight_failures/gdb_bug/test 

Breakpoint 1, asm_func () at asm.S:3
3           mov $0xdeadbeefdeadbeef, %rdi
(gdb) si
asm_func () at asm.S:4
4           ret
(gdb) b sig_handler
Breakpoint 2 at 0x55555555472c: file test.c, line 13.
(gdb) signal SIGVTALRM
Continuing with signal SIGVTALRM.

Breakpoint 2, sig_handler (sig=26) at test.c:13
13      }
(gdb) fin
Run till exit from #0  sig_handler (sig=26) at test.c:13
<signal handler called>
(gdb) 
Run till exit from #0  <signal handler called>
[Inferior 1 (process 29158) exited normally]
(gdb) 


I think the second finish should have taken me to the ret instruction at the
end of asm_func.

The test originally had "proper" signals in it -- so this isn't a bug in the
way 'signal' delivers signals.

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

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

* [Bug gdb/27613] finish from sigreturn trampoline sometimes doesn't stop
  2021-03-19 15:53 [Bug gdb/27613] New: finish from sigreturn trampoline sometimes doesn't stop ismith at undo dot io
@ 2021-03-19 15:56 ` ismith at undo dot io
  0 siblings, 0 replies; 2+ messages in thread
From: ismith at undo dot io @ 2021-03-19 15:56 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Isa Smith <ismith at undo dot io> ---
The transcript there is from gdb 8.1 but I tested this on
7b9f985957798ba4dacc454f22c9e426c6897cb8 from master and saw the same
behaviour.

Other info:
This GDB was configured as "x86_64-pc-linux-gnu".

$ uname -a
Linux brunost-thinkpad 5.4.0-67-generic #75~18.04.1-Ubuntu SMP Tue Feb 23
19:17:50 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

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

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

end of thread, other threads:[~2021-03-19 15:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 15:53 [Bug gdb/27613] New: finish from sigreturn trampoline sometimes doesn't stop ismith at undo dot io
2021-03-19 15:56 ` [Bug gdb/27613] " ismith at undo dot io

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).