public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/101669] New: error reading variable from debug information when compiling with -O2
@ 2021-07-29  6:28 guojiufu at gcc dot gnu.org
  2021-07-29  7:01 ` [Bug debug/101669] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2021-07-29  6:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101669
           Summary: error reading variable from debug information when
                    compiling with -O2
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: guojiufu at gcc dot gnu.org
  Target Milestone: ---

For below case:
----------gdb.f90
  integer :: a(10), b(12)
  call sub (a, 10)
  call sub (b, 12)
  write (*,*) a, b
end

subroutine sub (a, n)
  integer :: a(n), n
  integer(kind=8) nl, i
  nl = n

  do i = 1, nl
    a(i) = i
  end do
  write (*,*) a                                                  
end subroutine
------------
At -O2, using command "gfortran -O2 -g ~/temp/gdb.f90 -o arg1.exe" to compile,
when debugger it with gdb, there is log:
a=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF
expression.>

$ gdb arg1.exe
...
(gdb) b sub
Breakpoint 1 at 0x400710: file /home/guojiufu/temp/gdb.f90, line 7.
(gdb) r
Starting program: /home/guojiufu/gcc/build/gcc-mainline-base/arg1.exe 

Breakpoint 1, sub (a=<error reading variable: dwarf2_find_location_expression:
Corrupted DWARF expression.>, 
    n=10) at /home/guojiufu/temp/gdb.f90:7
7       subroutine sub (a, n)

This msg does not occur when compiling with -O3 -g.

This issue can be reproduced on x86/ppc64le with the latest trunk, and also
occur in gcc11.

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

* [Bug debug/101669] error reading variable from debug information when compiling with -O2
  2021-07-29  6:28 [Bug debug/101669] New: error reading variable from debug information when compiling with -O2 guojiufu at gcc dot gnu.org
@ 2021-07-29  7:01 ` rguenth at gcc dot gnu.org
  2021-07-29  8:46 ` guojiufu at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-29  7:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Version|11.0                        |11.1.1
           Keywords|                            |wrong-debug
                 CC|                            |jakub at gcc dot gnu.org
   Last reconfirmed|                            |2021-07-29
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
gdb doesn't complain for me but readelf does:

readelf: Warning: Location lists in .debug_loc section start at 0x10
readelf: Warning: Location list starting at offset 0x10 is not terminated.
readelf: Warning: Hole and overlap detection requires adjacent view lists and
loclists.
readelf: Warning: Location list starting at offset 0x2b is not terminated.
readelf: Warning: There is an overlap [0xe4 - 0x0] in .debug_loc section.

it doesn't happen with -gdwarf-4.  It also happens with GCC 9 and -gdwarf-5.
With GCC 7 and -gdwarf-5 there are many more complaints from readelf.

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

* [Bug debug/101669] error reading variable from debug information when compiling with -O2
  2021-07-29  6:28 [Bug debug/101669] New: error reading variable from debug information when compiling with -O2 guojiufu at gcc dot gnu.org
  2021-07-29  7:01 ` [Bug debug/101669] " rguenth at gcc dot gnu.org
@ 2021-07-29  8:46 ` guojiufu at gcc dot gnu.org
  2021-07-29 10:09 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2021-07-29  8:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
Similar to what Richard said,  tested with gdb, use -gdwarf-4 with trunk, the
msg also disappears.

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

* [Bug debug/101669] error reading variable from debug information when compiling with -O2
  2021-07-29  6:28 [Bug debug/101669] New: error reading variable from debug information when compiling with -O2 guojiufu at gcc dot gnu.org
  2021-07-29  7:01 ` [Bug debug/101669] " rguenth at gcc dot gnu.org
  2021-07-29  8:46 ` guojiufu at gcc dot gnu.org
@ 2021-07-29 10:09 ` jakub at gcc dot gnu.org
  2021-07-29 16:25 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-07-29 10:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This is weird.  There is no .debug_loc section with DWARF 5 at all, only
.debug_loclists.
I don't see any complains from readelf:
readelf --debug-dump=loc pr101669 >/dev/null
(binutils 2.36.1).
And no errors from gdb (10.2).
So isn't this because of too old gdb or binutils?

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

* [Bug debug/101669] error reading variable from debug information when compiling with -O2
  2021-07-29  6:28 [Bug debug/101669] New: error reading variable from debug information when compiling with -O2 guojiufu at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-07-29 10:09 ` jakub at gcc dot gnu.org
@ 2021-07-29 16:25 ` pinskia at gcc dot gnu.org
  2021-07-30  2:21 ` guojiufu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-29 16:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
What version of gdb are you using?

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

* [Bug debug/101669] error reading variable from debug information when compiling with -O2
  2021-07-29  6:28 [Bug debug/101669] New: error reading variable from debug information when compiling with -O2 guojiufu at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-07-29 16:25 ` pinskia at gcc dot gnu.org
@ 2021-07-30  2:21 ` guojiufu at gcc dot gnu.org
  2021-07-30  2:34 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2021-07-30  2:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> What version of gdb are you using?

Tried gdb8.1/8.3/9.2 on ppc64le.
In gdb, the msg "error reading variable: dwarf2_find_location_expression:"
occurs when stopping at the breakpoint 'sub' on the tip message:
------------
Breakpoint 1, 0x0000000100000a58 in sub (a=<error reading variable:
dwarf2_find_location_expression: Corrupted DWARF expression.>, n=10) at
/home/guojiufu/temp/gdb.f90:7
------------

readelf --debug-dump arg1.exe |grep readelf
readelf: Error: Invalid location list entry type 8
readelf: Warning: Hole and overlap detection requires adjacent view lists and
loclists.

--------
readelf -v
GNU readelf (GNU Binutils for Ubuntu) 2.34
readelf 2.30 can also get the Error/Warning msg.


gfortran -O2 -g ~/temp/gdb.f90 -gdwarf-5 -o arg1.exe

On x86 is similar, readelf2.30/gdb8.1 can reproduce the msg at my side.

Before gcc11, need -gdwarf-5 to reproduce since we default to this dwarf
version in gcc11.

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

* [Bug debug/101669] error reading variable from debug information when compiling with -O2
  2021-07-29  6:28 [Bug debug/101669] New: error reading variable from debug information when compiling with -O2 guojiufu at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-07-30  2:21 ` guojiufu at gcc dot gnu.org
@ 2021-07-30  2:34 ` pinskia at gcc dot gnu.org
  2021-07-30  2:58 ` pinskia at gcc dot gnu.org
  2021-07-30  3:04 ` guojiufu at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-30  2:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmmm, maybe https://sourceware.org/bugzilla/show_bug.cgi?id=27999

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

* [Bug debug/101669] error reading variable from debug information when compiling with -O2
  2021-07-29  6:28 [Bug debug/101669] New: error reading variable from debug information when compiling with -O2 guojiufu at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-07-30  2:34 ` pinskia at gcc dot gnu.org
@ 2021-07-30  2:58 ` pinskia at gcc dot gnu.org
  2021-07-30  3:04 ` guojiufu at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-30  2:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jiu Fu Guo from comment #5)
> readelf --debug-dump arg1.exe |grep readelf
> readelf: Error: Invalid location list entry type 8

    DW_LLE_start_length = 0x08,

Didn't make it into binutils until 2.35:
https://sourceware.org/pipermail/binutils/2020-November/114140.html


gdb support went in at
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;f=gdb/dwarf2/loc.c;h=3112ed9799124edf4d1f9c903da0d59f5a4ca102

Which did not make it until gdb 10.0.

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

* [Bug debug/101669] error reading variable from debug information when compiling with -O2
  2021-07-29  6:28 [Bug debug/101669] New: error reading variable from debug information when compiling with -O2 guojiufu at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-07-30  2:58 ` pinskia at gcc dot gnu.org
@ 2021-07-30  3:04 ` guojiufu at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2021-07-30  3:04 UTC (permalink / raw)
  To: gcc-bugs

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

Jiu Fu Guo <guojiufu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|NEW                         |RESOLVED

--- Comment #8 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> Hmmm, maybe https://sourceware.org/bugzilla/show_bug.cgi?id=27999

Thanks, Andrew.

Great! With the latest gdb from the trunk, it is ok. 

(gdb) b sub
Breakpoint 1 at 0xa58: file /home/guojiufu/temp/gdb.f90, line 9.
(gdb) b 17
Breakpoint 2 at 0xafc: file /home/guojiufu/temp/gdb.f90, line 17.
(gdb) r
Starting program: /home/guojiufu/temp/gdb/binutils-gdb/arg1.exe

Breakpoint 1, 0x0000000100000a58 in sub (a=..., n=10) at
/home/guojiufu/temp/gdb.f90:9
9       subroutine sub (a, n)
(gdb) c
Continuing.

Breakpoint 2, sub (a=..., n=10) at /home/guojiufu/temp/gdb.f90:17
17        write (*,*) a
(gdb) p a
$1 = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
(gdb) 

So, it seems not to be an issue from GCC, and works fine on with the latest
binutils.

Thanks all!

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

end of thread, other threads:[~2021-07-30  3:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29  6:28 [Bug debug/101669] New: error reading variable from debug information when compiling with -O2 guojiufu at gcc dot gnu.org
2021-07-29  7:01 ` [Bug debug/101669] " rguenth at gcc dot gnu.org
2021-07-29  8:46 ` guojiufu at gcc dot gnu.org
2021-07-29 10:09 ` jakub at gcc dot gnu.org
2021-07-29 16:25 ` pinskia at gcc dot gnu.org
2021-07-30  2:21 ` guojiufu at gcc dot gnu.org
2021-07-30  2:34 ` pinskia at gcc dot gnu.org
2021-07-30  2:58 ` pinskia at gcc dot gnu.org
2021-07-30  3:04 ` guojiufu 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).