Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 505333

Summary: Wrong access into unbound C arrays
Product: Red Hat Enterprise Linux 5 Reporter: Jan Kratochvil <jan.kratochvil>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED ERRATA QA Contact: BaseOS QE <qe-baseos-auto>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.4CC: cagney, ebachalo, pmuller
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gdb-6.8-37.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 505163 Environment:
Last Closed: 2009-09-02 11:27:14 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 505163    
Bug Blocks:    

Description Jan Kratochvil 2009-06-11 14:29:31 UTC
+++ This bug was initially created as a clone of Bug #505163 +++

Unbound C array (GCC extension - array[0] at an end of struct) cannot be accessed by RHEL-5.4 GDB due to a bug in the VLA (variable-length-array) RH patch.  RHEL-5.3 does not have this bug as it had no VLA/Fortran support.

Version-Release number of selected component (if applicable):
gdb-6.8-36.el5

How reproducible:
struct {
    int n;
    int a[0];
} b;

int
main (void)
{
  return 0;
}

Received result:
(gdb) p b->a
$1 = 0x600810
(gdb) p &b->a
$2 = (int (*)[]) 0x600810
(gdb) p &b->a[0]
$3 = (int *) 0xffffffffcf0508d0

Expected result:
(gdb) p b->a
$1 = 0x600810
(gdb) p &b->a
$2 = (int (*)[]) 0x600810
(gdb) p &b->a[0]
$3 = (int *) 0x600810

There is now a new testcase:
gdb.base/arrayidx.exp: p unbound.a == &unbound.a[0]

Comment 1 Jan Kratochvil 2009-06-11 14:34:20 UTC
Fix: http://sourceware.org/ml/archer-commits/2009-q2/msg00107.html

Comment 7 errata-xmlrpc 2009-09-02 11:27:14 UTC
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