[Bug 1886836] [NEW] gdb crashes on printing allocatable array in Fortran derived type

Manuel Engel 1886836 at bugs.launchpad.net
Wed Jul 8 15:20:36 UTC 2020


Public bug reported:

Package: gdb (8.1-0ubuntu3.2 Ubuntu:18.04/bionic-updates [amd64])
Ubuntu Release: Ubuntu 18.04.4 LTS

Bug occurs when trying to print allocatable or pointer component of a
Fortran derived-type structure in gdb.

Expected behavior:
gdb prints the contents of array BUFFER%ALPHA in the MWE below.

Observed behavior:

See upstream report
https://sourceware.org/bugzilla/show_bug.cgi?id=23051

When trying to print BUFFER%ALPHA, gdb crashes. The MWE copied form the
above link is:

  1 PROGRAM allocate_array                                                                                                                                    
  2                                                                                                                                                           
  3   TYPE L_BUFFER                                                                                                                                           
  4     REAL, DIMENSION(:), POINTER ::   ALPHA                                                                                                                
  5   END TYPE L_BUFFER                                                                                                                                       
  6   TYPE(L_BUFFER), POINTER :: BUFFER                                                                                                                       
  7                                                                                                                                                           
  8   ALLOCATE(BUFFER)                                                                                                                                        
  9                                                                                                                                                           
 10   ALLOCATE(BUFFER%ALPHA(5))                                                                                                                               
 11                                                                                                                                                           
 12   BUFFER%ALPHA(5)=0.0078                                                                                                                                  
 13   print *, buffer%alpha                                                                                                                                   
 14                                                                                                                                                           
 15 END PROGRAM allocate_array

And the gdb output reads:

Breakpoint 1, allocate_array () at allocate_array.F90:13                                                                                                  
13        print *, buffer%alpha                                                                                                                           
(gdb) i lo                                                                                                                                                
buffer = 0x603f80                                                                                                                                         
(gdb) p *buffer                                                                                                                                           
$1 = (                                                                                                                                                    
value.c:3116: internal-error: value* value_primitive_field(value*, LONGEST, int, type*): Assertion `PROP_CONST == TYPE_DATA_LOCATION_KIND (type)' failed. 
A problem internal to GDB has been detected,                                                                                                              
further debugging may prove unreliable.                                                                                                                   
Quit this debugging session? (y or n) n

The same error can be observed from inside a type-bound procedure when
trying to print THIS%ALPHA (where this is the instance variable).

The assertion fails since TYPE_DATA_LOCATION_KIND (type) is
PROP_LOCEXPR. A standalone allocatable array has the property type
PROP_CONST, as expected.

This bug renders debugging of Fortran code with visual tools (vscode,
eclipse, etc.) very difficult as the components are parsed
automatically, leading to a crash.

** Affects: gdb (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gdb in Ubuntu.
https://bugs.launchpad.net/bugs/1886836

Title:
  gdb crashes on printing allocatable array in Fortran derived type

Status in gdb package in Ubuntu:
  New

Bug description:
  Package: gdb (8.1-0ubuntu3.2 Ubuntu:18.04/bionic-updates [amd64])
  Ubuntu Release: Ubuntu 18.04.4 LTS

  Bug occurs when trying to print allocatable or pointer component of a
  Fortran derived-type structure in gdb.

  Expected behavior:
  gdb prints the contents of array BUFFER%ALPHA in the MWE below.

  Observed behavior:

  See upstream report
  https://sourceware.org/bugzilla/show_bug.cgi?id=23051

  When trying to print BUFFER%ALPHA, gdb crashes. The MWE copied form
  the above link is:

    1 PROGRAM allocate_array                                                                                                                                    
    2                                                                                                                                                           
    3   TYPE L_BUFFER                                                                                                                                           
    4     REAL, DIMENSION(:), POINTER ::   ALPHA                                                                                                                
    5   END TYPE L_BUFFER                                                                                                                                       
    6   TYPE(L_BUFFER), POINTER :: BUFFER                                                                                                                       
    7                                                                                                                                                           
    8   ALLOCATE(BUFFER)                                                                                                                                        
    9                                                                                                                                                           
   10   ALLOCATE(BUFFER%ALPHA(5))                                                                                                                               
   11                                                                                                                                                           
   12   BUFFER%ALPHA(5)=0.0078                                                                                                                                  
   13   print *, buffer%alpha                                                                                                                                   
   14                                                                                                                                                           
   15 END PROGRAM allocate_array

  And the gdb output reads:

  Breakpoint 1, allocate_array () at allocate_array.F90:13                                                                                                  
  13        print *, buffer%alpha                                                                                                                           
  (gdb) i lo                                                                                                                                                
  buffer = 0x603f80                                                                                                                                         
  (gdb) p *buffer                                                                                                                                           
  $1 = (                                                                                                                                                    
  value.c:3116: internal-error: value* value_primitive_field(value*, LONGEST, int, type*): Assertion `PROP_CONST == TYPE_DATA_LOCATION_KIND (type)' failed. 
  A problem internal to GDB has been detected,                                                                                                              
  further debugging may prove unreliable.                                                                                                                   
  Quit this debugging session? (y or n) n

  The same error can be observed from inside a type-bound procedure when
  trying to print THIS%ALPHA (where this is the instance variable).

  The assertion fails since TYPE_DATA_LOCATION_KIND (type) is
  PROP_LOCEXPR. A standalone allocatable array has the property type
  PROP_CONST, as expected.

  This bug renders debugging of Fortran code with visual tools (vscode,
  eclipse, etc.) very difficult as the components are parsed
  automatically, leading to a crash.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1886836/+subscriptions



More information about the foundations-bugs mailing list