Bug 465301 - GDB 6.8 can't index through slices of a fortran array
GDB 6.8 can't index through slices of a fortran array
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: gdb (Show other bugs)
5.3
All Linux
medium Severity medium
: rc
: ---
Assigned To: Jan Kratochvil
BaseOS QE
:
: 460384 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-10-02 12:55 EDT by Alan Matsuoka
Modified: 2010-10-23 00:54 EDT (History)
4 users (show)

See Also:
Fixed In Version: gdb-6.8-32.el5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-09-02 07:26:52 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
dwarf-stride.f90 (438 bytes, application/octet-stream)
2008-10-02 12:55 EDT, Alan Matsuoka
no flags Details

  None (edit)
Description Alan Matsuoka 2008-10-02 12:55:08 EDT
Created attachment 319263 [details]
dwarf-stride.f90

This is a follow-on to 215061. It looks like Jakub made the necessary changes to the tech-preview gfortran 4.3 so that it can handle the problem test case properly. The problem was that you had an array of structures and then assigned one of the members of the structure to another array of the same size but because the other members of the structure were there, the indexing was all wrong. This was a code generation problem, not just a DWARF problem. The best fix, to specify the stride in number of bytes rather than in number of elements is not possible at this time becuase it would change the fortran ABI. This won't be fixable until gcc 4.5 is being developed. Instead Jakub evidently specified the stride in a separate variable instead of the descriptor when GFC_DECL_SUBREF_ARRAY_P.

http://gcc.gnu.org/ml/fortran/2007-04/msg00114.html
http://gcc.gnu.org/ml/fortran/2007-09/msg00171.html

In this case, gdb 6.8 doesn't know how to handle individual element of passed arrays with unspecified size. It does understand how to traverse the whole array, yet when you try to access the elements of an array, it points at the wrong memory addresses and gives you apparently corrupt data.

[ben@x61 tmp]$ gfortran43 -g dwarf-stride.f90
[ben@x61 tmp]$ gdb a.out
GNU gdb Fedora (6.8-23.el5)
Copyright (C) 2008 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 "i386-redhat-linux-gnu"...
(gdb) b 20
Breakpoint 1 at 0x8048734: file dwarf-stride.f90, line 20.
(gdb) r
Starting program: /tmp/a.out

Breakpoint 1, repro () at dwarf-stride.f90:20
20        print *, c40pt
Current language:  auto; currently fortran
(gdb) p c40pt
$1 = ('0-hello', ' ' <repeats 33 times>, '1-hello', ' ' <repeats 33 times>, '2-hello', ' ' <repeats 33 times>, '3-hello', ' ' <repeats 33 times>, '4-hello', ' ' <repeats 33 times>, '5-hello', ' ' <repeats 33 times>, '6-hello', ' ' <repeats 33 times>, '7-hello', ' ' <repeats 33 times>, '8-hello', ' ' <repeats 33 times>, '9-hello', ' ' <repeats 33 times>, ':-hello', ' ' <repeats 33 times>, ';-hello', ' ' <repeats 33 times>, '<-hello', ' ' <repeats 33 times>, '=-hello', ' ' <repeats 33 times>, '>-hello', ' ' <repeats 33 times>, '?-hello', ' ' <repeats 33 times>, '@-hello', ' ' <repeats 33 times>, 'A-hello', ' ' <repeats 33 times>, 'B-hello', ' ' <repeats 33 times>, 'C-hello', ' ' <repeats 33 times>)
(gdb) p c40pt(1)
$2 = '0-hello', ' ' <repeats 33 times>
(gdb) p c40pt(2)
warning: Fortran array stride not divisible by the element size
$3 = '
Comment 1 Jan Kratochvil 2008-10-04 17:59:54 EDT
Fixed in:
http://people.redhat.com/jkratoch/vla/fortran-dynamic-arrays-HEAD-c.patch
Just this whole Fortran/VLA/DWARF-blocks patch will be rebased for RHEL-5.4.

GNU gdb (GDB) 6.8.50.20081003-cvs
Copyright (C) 2008 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-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(gdb) b 20
Breakpoint 1 at 0x400967: file dwarf-stride.f90, line 20.
(gdb) r
Starting program: /tmp/dwarf-stride 

Breakpoint 1, repro () at dwarf-stride.f90:20
20	  print *, c40pt
Current language:  auto; currently fortran
(gdb) p c40pt
$1 = ('0-hello', ' ' <repeats 33 times>, '1-hello', ' ' <repeats 33 times>, '2-hello', ' ' <repeats 33 times>, '3-hello', ' ' <repeats 33 times>, '4-hello', ' ' <repeats 33 times>, '5-hello', ' ' <repeats 33 times>, '6-hello', ' ' <repeats 33 times>, '7-hello', ' ' <repeats 33 times>, '8-hello', ' ' <repeats 33 times>, '9-hello', ' ' <repeats 33 times>, ':-hello', ' ' <repeats 33 times>, ';-hello', ' ' <repeats 33 times>, '<-hello', ' ' <repeats 33 times>, '=-hello', ' ' <repeats 33 times>, '>-hello', ' ' <repeats 33 times>, '?-hello', ' ' <repeats 33 times>, '@-hello', ' ' <repeats 33 times>, 'A-hello', ' ' <repeats 33 times>, 'B-hello', ' ' <repeats 33 times>, 'C-hello', ' ' <repeats 33 times>)
(gdb) p c40pt(1)
$2 = '0-hello', ' ' <repeats 33 times>
(gdb) p c40pt(2)
$3 = '1-hello', ' ' <repeats 33 times>
(gdb)
Comment 2 Jan Kratochvil 2008-10-05 17:24:20 EDT
*** Bug 460384 has been marked as a duplicate of this bug. ***
Comment 8 Chris Ward 2009-07-03 14:10:13 EDT
~~ Attention - RHEL 5.4 Beta Released! ~~

RHEL 5.4 Beta has been released! There should be a fix present in the Beta release that addresses this particular request. Please test and report back results here, at your earliest convenience. RHEL 5.4 General Availability release is just around the corner!

If you encounter any issues while testing Beta, please describe the issues you have encountered and set the bug into NEED_INFO. If you encounter new issues, please clone this bug to open a new issue and request it be reviewed for inclusion in RHEL 5.4 or a later update, if it is not of urgent severity.

Please do not flip the bug status to VERIFIED. Only post your verification results, and if available, update Verified field with the appropriate value.

Questions can be posted to this bug or your customer or partner representative.
Comment 11 errata-xmlrpc 2009-09-02 07:26:52 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-1361.html

Note You need to log in before you can comment on or make changes to this bug.