[Bug fortran/23051] New: internal-error for printing the contents of an allocated pointer of a derived type that contains an allocated pointer array

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/23051] New: internal-error for printing the contents of an allocated pointer of a derived type that contains an allocated pointer array

glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=23051

            Bug ID: 23051
           Summary: internal-error for printing the contents of an
                    allocated pointer of a derived type that contains an
                    allocated pointer array
           Product: gdb
           Version: 8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
          Assignee: unassigned at sourceware dot org
          Reporter: mysecmailboks at gmail dot com
  Target Milestone: ---

Hello,

this is similar to the bug report 15821 and I confirm that the 15821 has been
resolved in the release 8.1. I have modified the code sample given in 15821 and
I have a problem with it using release 8.1 (or the latest git master pulled
12th March 2018).

The code is the following:

  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                                                  

gdb:

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                                        

This is a bug, please report it.  For instructions, see:                        
<http://www.gnu.org/software/gdb/bugs/>.                                        

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.                                        
Create a core file of GDB? (y or n) n                                          
Command aborted.                                                                

Please advice

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/23051] internal-error for printing the contents of an allocated pointer of a derived type that contains an allocated pointer array

glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=23051

Alex Lindsay <alexlindsay239 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alexlindsay239 at gmail dot com

--- Comment #1 from Alex Lindsay <alexlindsay239 at gmail dot com> ---
I can confirm this bug on Ubuntu 16.04 using gdb-8.1

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/23051] internal-error for printing the contents of an allocated pointer of a derived type that contains an allocated pointer array

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=23051

findessp at yandex dot ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |findessp at yandex dot ru

--- Comment #2 from findessp at yandex dot ru ---
I can confirm this bug for version 8.3.1.

FWIW: ALPHA in the example given in the bug description can also be an
allocatable array for the bug to happen.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/23051] internal-error for printing the contents of an allocated pointer of a derived type that contains an allocated pointer array

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=23051

Marshall Ward <marshall.ward at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marshall.ward at gmail dot com

--- Comment #3 from Marshall Ward <marshall.ward at gmail dot com> ---
I am seeing this problem in GDB 9.1 build locally.  Repeating the instruction
above.

(gdb) p buffer%alpha
../../gdb-9.1/gdb/value.c:2988: 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.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/23051] internal-error for printing the contents of an allocated pointer of a derived type that contains an allocated pointer array

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=23051

--- Comment #4 from Marshall Ward <marshall.ward at gmail dot com> ---
I ran gdb through gdb (there's a sentence I never thought I'd write) and it
appears that `buffer%alpha` is being treated as a PROP_LOCEXPR and not a
PROP_CONST:

(gdb) p *get_dyn_prop(DYN_PROP_DATA_LOCATION, type)
$9 = {kind = PROP_LOCEXPR, data = {const_val = 93937133865712, baton =
0x556f717ecaf0}}

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/23051] internal-error for printing the contents of an allocated pointer of a derived type that contains an allocated pointer array

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=23051

Andrew Burgess <andrew.burgess at embecosm dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrew.burgess at embecosm dot com

--- Comment #5 from Andrew Burgess <andrew.burgess at embecosm dot com> ---
This issue is resolved by the patches I posted here:
  https://sourceware.org/pipermail/gdb-patches/2020-July/170333.html

I'll update the ChangeLog for those patches to ensure I reference this bug, and
I'll extend the patch to include tests that cover this issue too.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/23051] internal-error for printing the contents of an allocated pointer of a derived type that contains an allocated pointer array

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=23051

--- Comment #6 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Burgess <[hidden email]>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e79eb02f2f09baecffb144bac6804f975065466f

commit e79eb02f2f09baecffb144bac6804f975065466f
Author: Andrew Burgess <[hidden email]>
Date:   Thu Jul 9 16:26:23 2020 +0100

    gdb/fortran: resolve dynamic types when readjusting after an indirection

    After dereferencing a pointer (in value_ind) or following a
    reference (in coerce_ref) we call readjust_indirect_value_type to
    "fixup" the type of the resulting value object.

    This fixup handles cases relating to the type of the resulting object
    being different (a sub-class) of the original pointers target type.

    If we encounter a pointer to a dynamic type then after dereferencing a
    pointer (in value_ind) the type of the object created will have had
    its dynamic type resolved.  However, in readjust_indirect_value_type,
    we use the target type of the original pointer to "fixup" the type of
    the resulting value.  In this case, the target type will be a dynamic
    type, so the resulting value object, once again has a dynamic type.

    This then triggers an assertion later within GDB.

    The solution I propose here is that we call resolve_dynamic_type on
    the pointer's target type (within readjust_indirect_value_type) so
    that the resulting value is not converted back to a dynamic type.

    The test case is based on the original test in the bug report.

    gdb/ChangeLog:

            PR fortran/23051
            PR fortran/26139
            * valops.c (value_ind): Pass address to
            readjust_indirect_value_type.
            * value.c (readjust_indirect_value_type): Make parameter
            non-const, and add extra address parameter.  Resolve original type
            before using it.
            * value.h (readjust_indirect_value_type): Update function
            signature and comment.

    gdb/testsuite/ChangeLog:

            PR fortran/23051
            PR fortran/26139
            * gdb.fortran/class-allocatable-array.exp: New file.
            * gdb.fortran/class-allocatable-array.f90: New file.
            * gdb.fortran/pointer-to-pointer.exp: New file.
            * gdb.fortran/pointer-to-pointer.f90: New file.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/23051] internal-error for printing the contents of an allocated pointer of a derived type that contains an allocated pointer array

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=23051

Andrew Burgess <andrew.burgess at embecosm dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Andrew Burgess <andrew.burgess at embecosm dot com> ---
This issue should now be resolved.

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