public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59090] New: Broken debug information for a function containing __sync_compare_and_swap
@ 2013-11-12 17:33 kostja.osipov at gmail dot com
  2013-11-14  8:49 ` [Bug c/59090] [4.7 Regression] " rguenth at gcc dot gnu.org
  2014-06-12 13:31 ` [Bug debug/59090] " rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: kostja.osipov at gmail dot com @ 2013-11-12 17:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59090

            Bug ID: 59090
           Summary: Broken debug information for a function containing
                    __sync_compare_and_swap
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kostja.osipov at gmail dot com

gcc 4.6.3 fails to produce a correct debuggable binary when a function uses
an atomic built-iin and an infinite loop.

In the example below a breakpoint on 'pop' never hits, even though pop is
clearly called from main.

kostja@olah ~ % cat bug.c 
void *
pop(void **ptr)
{
    for (;;) {
        void *p=  *ptr;
        if (__sync_val_compare_and_swap(ptr, p, 0) == p)
            return p;
    }
}

int main()
{
    void *ptr = 0;
    void *val = pop(&ptr);

    return 0;
}

kostja@olah ~ % gcc -O0 -g bug.c; gdb ./a.out 
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/kostja/a.out...done.
(gdb) b pop
Breakpoint 1 at 0x4004be: file bug.c, line 8.
(gdb) run
Starting program: /home/kostja/a.out 
[Inferior 1 (process 1034) exited normally]


kostja@olah ~ % gcc -O0 -ggdb -S bug.c 
kostja@olah ~ % cat bug.s 
    .file    "bug.c"
    .text
.Ltext0:
    .globl    pop
    .type    pop, @function
pop:
.LFB0:
    .file 1 "bug.c"
    .loc 1 3 0
    .cfi_startproc
    pushq    %rbp
.LCFI0:
    .cfi_def_cfa_offset 16
    .cfi_offset 6, -16
    movq    %rsp, %rbp
.LCFI1:
    .cfi_def_cfa_register 6
    movq    %rdi, -24(%rbp)
    jmp    .L3
.L4:
    .loc 1 8 0
    nop
.L3:
.LBB2:
    .loc 1 5 0
    movq    -24(%rbp), %rax
    movq    (%rax), %rax
    movq    %rax, -8(%rbp)
    .loc 1 6 0
    movq    -8(%rbp), %rax
    movq    -24(%rbp), %rdx
    movl    $0, %ecx
    lock cmpxchgq    %rcx, (%rdx)
    cmpq    -8(%rbp), %rax
    jne    .L4
    .loc 1 7 0
    movq    -8(%rbp), %rax
.LBE2:
    .loc 1 9 0
    popq    %rbp
.LCFI2:
    .cfi_def_cfa 7, 8
    ret
    .cfi_endproc
.LFE0:
    .size    pop, .-pop
    .globl    main
    .type    main, @function
main:
.LFB1:
    .loc 1 12 0
    .cfi_startproc
    pushq    %rbp
.LCFI3:
    .cfi_def_cfa_offset 16
    .cfi_offset 6, -16
    movq    %rsp, %rbp
.LCFI4:
    .cfi_def_cfa_register 6
    subq    $16, %rsp
    .loc 1 13 0
    movq    $0, -16(%rbp)
    .loc 1 14 0
    leaq    -16(%rbp), %rax
    movq    %rax, %rdi
    call    pop
    movq    %rax, -8(%rbp)
    .loc 1 16 0
    movl    $0, %eax
    .loc 1 17 0
    leave
.LCFI5:
    .cfi_def_cfa 7, 8
    ret
    .cfi_endproc
.LFE1:
    .size    main, .-main
.Letext0:
    .section    .debug_info,"",@progbits
.Ldebug_info0:
    .long    0xcc
    .value    0x2
    .long    .Ldebug_abbrev0
    .byte    0x8
    .uleb128 0x1
    .long    .LASF0
    .byte    0x1
    .long    .LASF1
    .long    .LASF2
    .quad    .Ltext0
    .quad    .Letext0
    .long    .Ldebug_line0
    .uleb128 0x2
    .byte    0x1
    .string    "pop"
    .byte    0x1
    .byte    0x2
    .byte    0x1
    .long    0x7f
    .quad    .LFB0
    .quad    .LFE0
    .long    .LLST0
    .long    0x7f
    .uleb128 0x3
    .string    "ptr"
    .byte    0x1
    .byte    0x2
    .long    0x81
    .byte    0x2
    .byte    0x91
    .sleb128 -40
    .uleb128 0x4
    .quad    .LBB2
    .quad    .LBE2
    .uleb128 0x5
    .string    "p"
    .byte    0x1
    .byte    0x5
    .long    0x7f
    .byte    0x2
    .byte    0x91
    .sleb128 -24
    .byte    0
    .byte    0
    .uleb128 0x6
    .byte    0x8
    .uleb128 0x7
    .byte    0x8
    .long    0x7f
    .uleb128 0x8
    .byte    0x1
    .long    .LASF3
    .byte    0x1
    .byte    0xb
    .long    0xc8
    .quad    .LFB1
    .quad    .LFE1
    .long    .LLST1
    .long    0xc8
    .uleb128 0x5
    .string    "ptr"
    .byte    0x1
    .byte    0xd
    .long    0x7f
    .byte    0x2
    .byte    0x91
    .sleb128 -32
    .uleb128 0x5
    .string    "val"
    .byte    0x1
    .byte    0xe
    .long    0x7f
    .byte    0x2
    .byte    0x91
    .sleb128 -24
    .byte    0
    .uleb128 0x9
    .byte    0x4
    .byte    0x5
    .string    "int"
    .byte    0
    .section    .debug_abbrev,"",@progbits
.Ldebug_abbrev0:
    .uleb128 0x1
    .uleb128 0x11
    .byte    0x1
    .uleb128 0x25
    .uleb128 0xe
    .uleb128 0x13
    .uleb128 0xb
    .uleb128 0x3
    .uleb128 0xe
    .uleb128 0x1b
    .uleb128 0xe
    .uleb128 0x11
    .uleb128 0x1
    .uleb128 0x12
    .uleb128 0x1
    .uleb128 0x10
    .uleb128 0x6
    .byte    0
    .byte    0
    .uleb128 0x2
    .uleb128 0x2e
    .byte    0x1
    .uleb128 0x3f
    .uleb128 0xc
    .uleb128 0x3
    .uleb128 0x8
    .uleb128 0x3a
    .uleb128 0xb
    .uleb128 0x3b
    .uleb128 0xb
    .uleb128 0x27
    .uleb128 0xc
    .uleb128 0x49
    .uleb128 0x13
    .uleb128 0x11
    .uleb128 0x1
    .uleb128 0x12
    .uleb128 0x1
    .uleb128 0x40
    .uleb128 0x6
    .uleb128 0x1
    .uleb128 0x13
    .byte    0
    .byte    0
    .uleb128 0x3
    .uleb128 0x5
    .byte    0
    .uleb128 0x3
    .uleb128 0x8
    .uleb128 0x3a
    .uleb128 0xb
    .uleb128 0x3b
    .uleb128 0xb
    .uleb128 0x49
    .uleb128 0x13
    .uleb128 0x2
    .uleb128 0xa
    .byte    0
    .byte    0
    .uleb128 0x4
    .uleb128 0xb
    .byte    0x1
    .uleb128 0x11
    .uleb128 0x1
    .uleb128 0x12
    .uleb128 0x1
    .byte    0
    .byte    0
    .uleb128 0x5
    .uleb128 0x34
    .byte    0
    .uleb128 0x3
    .uleb128 0x8
    .uleb128 0x3a
    .uleb128 0xb
    .uleb128 0x3b
    .uleb128 0xb
    .uleb128 0x49
    .uleb128 0x13
    .uleb128 0x2
    .uleb128 0xa
    .byte    0
    .byte    0
    .uleb128 0x6
    .uleb128 0xf
    .byte    0
    .uleb128 0xb
    .uleb128 0xb
    .byte    0
    .byte    0
    .uleb128 0x7
    .uleb128 0xf
    .byte    0
    .uleb128 0xb
    .uleb128 0xb
    .uleb128 0x49
    .uleb128 0x13
    .byte    0
    .byte    0
    .uleb128 0x8
    .uleb128 0x2e
    .byte    0x1
    .uleb128 0x3f
    .uleb128 0xc
    .uleb128 0x3
    .uleb128 0xe
    .uleb128 0x3a
    .uleb128 0xb
    .uleb128 0x3b
    .uleb128 0xb
    .uleb128 0x49
    .uleb128 0x13
    .uleb128 0x11
    .uleb128 0x1
    .uleb128 0x12
    .uleb128 0x1
    .uleb128 0x40
    .uleb128 0x6
    .uleb128 0x1
    .uleb128 0x13
    .byte    0
    .byte    0
    .uleb128 0x9
    .uleb128 0x24
    .byte    0
    .uleb128 0xb
    .uleb128 0xb
    .uleb128 0x3e
    .uleb128 0xb
    .uleb128 0x3
    .uleb128 0x8
    .byte    0
    .byte    0
    .byte    0
    .section    .debug_loc,"",@progbits
.Ldebug_loc0:
.LLST0:
    .quad    .LFB0-.Ltext0
    .quad    .LCFI0-.Ltext0
    .value    0x2
    .byte    0x77
    .sleb128 8
    .quad    .LCFI0-.Ltext0
    .quad    .LCFI1-.Ltext0
    .value    0x2
    .byte    0x77
    .sleb128 16
    .quad    .LCFI1-.Ltext0
    .quad    .LCFI2-.Ltext0
    .value    0x2
    .byte    0x76
    .sleb128 16
    .quad    .LCFI2-.Ltext0
    .quad    .LFE0-.Ltext0
    .value    0x2
    .byte    0x77
    .sleb128 8
    .quad    0
    .quad    0
.LLST1:
    .quad    .LFB1-.Ltext0
    .quad    .LCFI3-.Ltext0
    .value    0x2
    .byte    0x77
    .sleb128 8
    .quad    .LCFI3-.Ltext0
    .quad    .LCFI4-.Ltext0
    .value    0x2
    .byte    0x77
    .sleb128 16
    .quad    .LCFI4-.Ltext0
    .quad    .LCFI5-.Ltext0
    .value    0x2
    .byte    0x76
    .sleb128 16
    .quad    .LCFI5-.Ltext0
    .quad    .LFE1-.Ltext0
    .value    0x2
    .byte    0x77
    .sleb128 8
    .quad    0
    .quad    0
    .section    .debug_aranges,"",@progbits
    .long    0x2c
    .value    0x2
    .long    .Ldebug_info0
    .byte    0x8
    .byte    0
    .value    0
    .value    0
    .quad    .Ltext0
    .quad    .Letext0-.Ltext0
    .quad    0
    .quad    0
    .section    .debug_line,"",@progbits
.Ldebug_line0:
    .section    .debug_str,"MS",@progbits,1
.LASF2:
    .string    "/home/kostja"
.LASF0:
    .string    "GNU C 4.6.3"
.LASF1:
    .string    "bug.c"
.LASF3:
    .string    "main"
    .ident    "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3"
    .section    .note.GNU-stack,"",@progbits


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

* [Bug c/59090] [4.7 Regression] Broken debug information for a function containing __sync_compare_and_swap
  2013-11-12 17:33 [Bug c/59090] New: Broken debug information for a function containing __sync_compare_and_swap kostja.osipov at gmail dot com
@ 2013-11-14  8:49 ` rguenth at gcc dot gnu.org
  2014-06-12 13:31 ` [Bug debug/59090] " rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-11-14  8:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59090

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-14
      Known to work|                            |4.3.6, 4.8.3, 4.9.0
   Target Milestone|---                         |4.7.4
            Summary|Broken debug information    |[4.7 Regression] Broken
                   |for a function containing   |debug information for a
                   |__sync_compare_and_swap     |function containing
                   |                            |__sync_compare_and_swap
     Ever confirmed|0                           |1
      Known to fail|                            |4.6.3, 4.7.3

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed with 4.6.3 and 4.7.3, works with 4.8.3 and 4.9.0 and also 4.3.6.


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

* [Bug debug/59090] [4.7 Regression] Broken debug information for a function containing __sync_compare_and_swap
  2013-11-12 17:33 [Bug c/59090] New: Broken debug information for a function containing __sync_compare_and_swap kostja.osipov at gmail dot com
  2013-11-14  8:49 ` [Bug c/59090] [4.7 Regression] " rguenth at gcc dot gnu.org
@ 2014-06-12 13:31 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-12 13:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59090

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|4.7.4                       |4.8.3
      Known to fail|                            |4.7.4

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for 4.8.3.


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

end of thread, other threads:[~2014-06-12 13:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-12 17:33 [Bug c/59090] New: Broken debug information for a function containing __sync_compare_and_swap kostja.osipov at gmail dot com
2013-11-14  8:49 ` [Bug c/59090] [4.7 Regression] " rguenth at gcc dot gnu.org
2014-06-12 13:31 ` [Bug debug/59090] " rguenth 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).