public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/26870] New: [fortran] Printing dynamic array fails
@ 2020-11-12 12:50 vries at gcc dot gnu.org
  2020-11-12 12:56 ` [Bug fortran/26870] " vries at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2020-11-12 12:50 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 26870
           Summary: [fortran] Printing dynamic array fails
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: fortran
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider test-case gdb.fortran/dynamic.exp, as added in fedora patch
https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer-vla-tests.patch
.

When building current trunk gdb with CFLAGS/CXXFLAGS as in the openSUSE Leap
15.2 gdb package:
...
CFLAGS="-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2
-fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables
-fstack-clash-protection -g"
CXXFLAGS="$CFLAGS -Wno-error=odr"
...
we run into:
...
(gdb) PASS: gdb.fortran/dynamic.exp: ptype vart
p varz^M
$26 = (warning: array or string index out of range^M
<error reading variable>^M
(gdb) FAIL: gdb.fortran/dynamic.exp: p varz
...

This can be reproduced on the command line:
...
$ gdb -batch dynamic \
    -ex "b 68" \
    -ex r \
    -ex "p varz" 
Breakpoint 1 at 0x400aac: file dynamic.f90, line 68.

Breakpoint 1, bar (varz=..., vart=...) at dynamic.f90:68
68        varz(2) = 5                                   ! varz-almostfilled^M
$1 = (warning: array or string index out of range
<error reading variable>
...

The problem is here, in f77_print_array_1.  Before calling get_discrete_bounds,
upperbound is uninitialized, and randomly set to a large value:
...
120       get_discrete_bounds (range_type, &lowerbound, &upperbound);
(gdb) p lowerbound
$1 = 0
(gdb) p upperbound
$2 = 31290496
...

Stepping into get_discrete_bounds, we can see that it returns -1:
...
(gdb) s
get_discrete_bounds ()
    at gdbtypes.c:1045
1045    {
(gdb) fin
Run till exit from #0  get_discrete_bounds ()
    at gdbtypes.c:1045
f77_print_array_1 ()
    at f-valprint.c:122
122       if (nss != ndimensions)
Value returned is $3 = -1
...
and the bounds are unchanged:
...
(gdb) p lowerbound
$4 = 0
(gdb) p upperbound
$5 = 31290496
...
which causes the warning and error.

And get_discrete_bounds returns -1 because:
...
(gdb) p type.main_type.flds_bnds.bounds.low
$18 = {m_kind = PROP_CONST, m_data = {const_val = 1, baton = 0x1, variant_parts
= 0x1, 
    original_type = 0x1}}
(gdb) p type.main_type.flds_bnds.bounds.high
$19 = {m_kind = PROP_UNDEFINED, m_data = {const_val = 6003792, 
    baton = 0x5b9c50 <check_typedef(type*)+464>, 
    variant_parts = 0x5b9c50 <check_typedef(type*)+464>, 
    original_type = 0x5b9c50 <check_typedef(type*)+464>}}
...

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

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

end of thread, other threads:[~2021-10-13 14:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 12:50 [Bug fortran/26870] New: [fortran] Printing dynamic array fails vries at gcc dot gnu.org
2020-11-12 12:56 ` [Bug fortran/26870] " vries at gcc dot gnu.org
2021-10-13 12:22 ` vries at gcc dot gnu.org
2021-10-13 14:06 ` [Bug symtab/26870] " vries at gcc dot gnu.org
2021-10-13 14:07 ` vries at gcc dot gnu.org
2021-10-13 14:07 ` vries at gcc dot gnu.org
2021-10-13 14:08 ` 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).