Bug 2012976 - GDB's Fortran lexical analyzer can mis-categorize symbol tokens
Summary: GDB's Fortran lexical analyzer can mis-categorize symbol tokens
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: 35
Hardware: All
OS: All
unspecified
low
Target Milestone: ---
Assignee: Kevin Buettner
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-10-11 18:21 UTC by Kevin Buettner
Modified: 2022-12-13 15:40 UTC (History)
9 users (show)

Fixed In Version: gdb-11.1-2.fc34
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-12-13 15:40:02 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Kevin Buettner 2021-10-11 18:21:31 UTC
Description of problem:

When debugging Fortran code, GDB will sometimes miscategorize a symbol token.

Consider the test case for gdb.fortran/array-slices.exp. I tested this on Fedora 35 with glibc debuginfo installed.

[kev@f35-1 gdb]$ ./gdb -q testsuite/outputs/gdb.fortran/array-slices/array-slices 
Reading symbols from testsuite/outputs/gdb.fortran/array-slices/array-slices...
(gdb) b show_str
Breakpoint 1 at 0x404586: file /ironwood1/sourceware-git/f35-master/bld/../../worktree-master/gdb/testsuite/gdb.fortran/array-slices.f90, line 41.
(gdb) run
Starting program: /mesquite2/sourceware-git/f35-master/bld/gdb/testsuite/outputs/gdb.fortran/array-slices/array-slices 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
 

Breakpoint 1, show_str (array=..., _array=26) at /ironwood1/sourceware-git/f35-master/bld/../../worktree-master/gdb/testsuite/gdb.fortran/array-slices.f90:41
41	end subroutine show_str
(gdb) p array
Attempt to use a type name as an expression

The reason for this behavior is that yylex() (which turns into f_yylex() in a gdb build) in gdb/f-exp.c searches, in sequence, STRUCT_DOMAIN, VAR_DOMAIN, and MODULE_DOMAIN for the symbol, stopping when it finds a match. However, there might be more than one match and some of the matches might be better than the others.  In this particular instance, it turns out that GDB is finding 'struct array' in glibc:

 <1><1ef36d>: Abbrev Number: 48 (DW_TAG_structure_type)
    <1ef36e>   DW_AT_name        : (indirect string, offset: 0x2c46f): array
    <1ef372>   DW_AT_byte_size   : 152
    <1ef373>   DW_AT_decl_file   : 5
    <1ef374>   DW_AT_decl_line   : 126
    <1ef375>   DW_AT_decl_column : 8
    <1ef375>   DW_AT_sibling     : <0x1ef38c>

This comes from glibc's nss/nss_files/file-hosts.c due to DYNARRAY construction.

Version-Release number of selected component (if applicable):

Problem observed on Fedora 35 with glibc debuginfo installed.  Until this bug is fixed, version number / release number of GDB is not important.  I.e. it should exist in all versions of GDB including and prior to gdb-11.1-2.

How reproducible:

Always, when conflicting symbols from some other library are present.

Steps to Reproduce:
1. 

From GDB's build directory, do:

make check TESTS="gdb.fortran/array-slices-bad.exp gdb.fortran/array-slices.exp"

2.

Debug the test case executable as shown above.

Actual results:

See above.

Expected results:

(gdb) p array
$1 = 'abcdefghijklmnopqrstuvwxyz'

Additional info:

An upstream commit contains changes which paper over the test suite failures that I observed while testing GDB 11.1 for Fedora 35.  There is still a bug in GDB, however; these changes to the test suite do not fix it.

I am, however, applying that patch to GDB 11.1 in order to obtain test results which are easier to compare than the alternative.

Comment 1 Fedora Update System 2021-10-19 03:46:16 UTC
FEDORA-2021-9f1f3732e0 has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2021-9f1f3732e0

Comment 2 Fedora Update System 2021-10-19 16:13:08 UTC
FEDORA-2021-9f1f3732e0 has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-9f1f3732e0`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-9f1f3732e0

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 3 Fedora Update System 2021-11-05 01:54:58 UTC
FEDORA-2021-9f1f3732e0 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 4 Kevin Buettner 2022-02-06 02:11:35 UTC
Reopening this...

We pushed a patch to our test suite which papers over the problem.  The bug hasn't actually been fixed in GDB.

It's still a problem in F35 and rawhide.

Comment 5 Ben Cotton 2022-11-29 17:08:44 UTC
This message is a reminder that Fedora Linux 35 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '35'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 35 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 6 Ben Cotton 2022-12-13 15:40:02 UTC
Fedora Linux 35 entered end-of-life (EOL) status on 2022-12-13.

Fedora Linux 35 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.


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