public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type
@ 2014-01-04 23:38 talebi.hossein at gmail dot com
  2014-01-05 12:53 ` [Bug fortran/59678] " talebi.hossein at gmail dot com
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: talebi.hossein at gmail dot com @ 2014-01-04 23:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

            Bug ID: 59678
           Summary: Segmentation fault on equalizing variables of a
                    complex derived data type
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: talebi.hossein at gmail dot com

Hi,

Unfortunetely I could not repeat this with a simpler test example. So this code
below runs fine with Intel compiler but fails with Gfortan. The is the main
file can be replaced in my code from here:

http://sourceforge.net/p/permix/git_pub/ci/master/tree/ 
The minimalitsic serial version can be compiled with 'make minimal_serial'.


program permix

   use permix_cmd_handling_mod
   use prx_class, only: ty_prx
   implicit none

   ! ty_prx is a complex derived data type
   type(ty_prx) :: prx, prx2


   ! initializing prx
   Call prx_init(prx,0,'mylog')

   ! running a simulation with giving an input
   call prx%input%job('../verif/Test1/linearelastic_nonsolver.prx ')

   ! prininting a part of the data
   print *,prx%parts%parts_fem(1)%OBJ%femmesh%X

   prx2=prx ! ERROR: Segmentation fault occurs here

end program permix



Here is the definition of ty_prx:

    type :: ty_prx
        character(200)                     :: title
        logical                            :: isInit=.false.
        integer                            :: revision=1183
        type(ty_input)                     :: input
        type(ty_part)                      :: parts
        type(ty_interaction)               :: interactions
        type(ty_define)                    :: define
        type(ty_analysis)                  :: analysis
        type(ty_modify)                    :: modify
        type(ty_initial_condition)         :: initial_conditions
        type(ty_solver)                    :: solver
        type(ty_output)                    :: output
        type(ty_tools)                     :: tools
        type(ty_restart)                   :: restart
        type(ty_timer)                     :: timer
        type(ty_universe)                  :: universe
        type(ty_error)                     :: error
        type(ty_prx_pointers)              :: pointers

        contains
            !procedure :: init      => prx_init
            procedure :: finalize  => prx_finalize  ! 
    end type ty_prx


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] Segmentation fault on equalizing variables of a complex derived data type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
@ 2014-01-05 12:53 ` talebi.hossein at gmail dot com
  2014-01-05 13:17 ` janus at gcc dot gnu.org
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: talebi.hossein at gmail dot com @ 2014-01-05 12:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #2 from Hossein Talebi <talebi.hossein at gmail dot com> ---

I tried but I could not get it with a simple test case. It will take me 1-2
full days until I reduce my code to a minimalistic example. I know you GCC guys
don't like this kind of error reporting; I understand; but I am quite busy too.
Let's find a compromise..


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] Segmentation fault on equalizing variables of a complex derived data type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
  2014-01-05 12:53 ` [Bug fortran/59678] " talebi.hossein at gmail dot com
@ 2014-01-05 13:17 ` janus at gcc dot gnu.org
  2014-01-05 14:30 ` talebi.hossein at gmail dot com
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-05 13:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #3 from janus at gcc dot gnu.org ---
(In reply to Hossein Talebi from comment #2)
> I tried but I could not get it with a simple test case. It will take me 1-2
> full days until I reduce my code to a minimalistic example.

A gfortran developer who is not familiar with your code would probably need
even more time than you to do this.


> I know you GCC
> guys don't like this kind of error reporting; I understand; but I am quite
> busy too. Let's find a compromise..

I tried to build your full code and got errors like this:

gfortran: error: ../../externals/lib_LNX64_SRL_GCC4.63/libmpiseq.a: No such
file or directory

If you expect that anyone looks into the problem, you will have to provide a
self-contained and reproducible test case. Simple as that.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] Segmentation fault on equalizing variables of a complex derived data type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
  2014-01-05 12:53 ` [Bug fortran/59678] " talebi.hossein at gmail dot com
  2014-01-05 13:17 ` janus at gcc dot gnu.org
@ 2014-01-05 14:30 ` talebi.hossein at gmail dot com
  2014-01-05 15:45 ` dominiq at lps dot ens.fr
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: talebi.hossein at gmail dot com @ 2014-01-05 14:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #4 from Hossein Talebi <talebi.hossein at gmail dot com> ---
Created attachment 31574
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31574&action=edit
test case, permix.f90 and the external

Please replace the contents of permix.f90 with this below. Put the attached
libmpiseq.a into  permix_home/externals/lib_LNX64_SRL_GCC4.63/  . Compile
again. It should be fine now. The executable will be in the permix_home/bin
folder. If this did not work, I will generate a test case next week. 


program permix

   use permix_cmd_handling_mod
   use prx_class, only: ty_prx
   implicit none

   ! ty_prx is a complex derived data type
   type(ty_prx) :: prx, prx2


   ! initializing prx
   Call prx_init(prx,0,'mylog')

   ! running a simulation with giving an input
   call prx%input%job('../verif/Test1/linearelastic_nonsolver.prx ')

   ! prininting a part of the data
   print *,prx%parts%parts_fem(1)%OBJ%femmesh%X

   prx2=prx ! ERROR: Segmentation fault occurs here

end program permix


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] Segmentation fault on equalizing variables of a complex derived data type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (2 preceding siblings ...)
  2014-01-05 14:30 ` talebi.hossein at gmail dot com
@ 2014-01-05 15:45 ` dominiq at lps dot ens.fr
  2014-01-05 17:32 ` talebi.hossein at gmail dot com
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-01-05 15:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-01-05
     Ever confirmed|0                           |1

--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
After providing the link to the openmpi library, the executable is generated
but fails at runtime with:

[Book15] permix_home/src% ../bin/permix_minimal_serial
*** The MPI_Comm_f2c() function was called before MPI_INIT was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.
[Book15.local:34330] Local abort before MPI_INIT completed successfully; not
able to aggregate error messages, and not able to guarantee that all other
processes were killed!

BTW I don't understand why serial make needs mpi stuff.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] Segmentation fault on equalizing variables of a complex derived data type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (3 preceding siblings ...)
  2014-01-05 15:45 ` dominiq at lps dot ens.fr
@ 2014-01-05 17:32 ` talebi.hossein at gmail dot com
  2014-01-05 20:18 ` dominiq at lps dot ens.fr
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: talebi.hossein at gmail dot com @ 2014-01-05 17:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #6 from Hossein Talebi <talebi.hossein at gmail dot com> ---
Thank you for trying it. Please spend 5 minutes to read and follow this. I
have attached a zip files in proper folder which you have to overwrite to
your local copy of PERMIX. I have modified the these to make it easy to
compile and test.

Method 1)

You have OpenMPI or another mpi library and you want to compile PERMIX with
it. After you overwrote the Makefile.minimal_mpi in the src/MAKE, just go
to permix_home/src and type 'make minimal_mpi'.
This will only need mpif90, mpicc and mpic++ to compile.

That error you reported happened because you have not initialized MPI.
Maybe if you add MPI initialization commands it will fix. But, I have
updated the new permix.f90 with these commands and you just replace it.

Method 2)
You want to compile PERMIX in a full serial version. This case you need to
supply some dummy MPI functions which are located in permix_home/src/STUBS
folder. I have precompiled them (in the attached file,
permix_home/externals/libmpiseq.a ). In case you have to compile
libmpiseq.a by yourself go to permix_home/src/STUBS and run  'build.sh'
which is the simplest way of compiling and linking in Linux.

So, when you have the libmpiseq.a in the right place go to src folder and
type 'make minimal_serial' .


Please do not forget to replace every single file that I attached now,
otherwise it won't work.

Cheers
Hossein











On Sun, Jan 5, 2014 at 4:45 PM, dominiq at lps dot ens.fr <
gcc-bugzilla@gcc.gnu.org> wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678
>
> Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>              Status|UNCONFIRMED                 |WAITING
>    Last reconfirmed|                            |2014-01-05
>      Ever confirmed|0                           |1
>
> --- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> After providing the link to the openmpi library, the executable is
> generated
> but fails at runtime with:
>
> [Book15] permix_home/src% ../bin/permix_minimal_serial
> *** The MPI_Comm_f2c() function was called before MPI_INIT was invoked.
> *** This is disallowed by the MPI standard.
> *** Your MPI job will now abort.
> [Book15.local:34330] Local abort before MPI_INIT completed successfully;
> not
> able to aggregate error messages, and not able to guarantee that all other
> processes were killed!
>
> BTW I don't understand why serial make needs mpi stuff.
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You reported the bug.
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] Segmentation fault on equalizing variables of a complex derived data type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (4 preceding siblings ...)
  2014-01-05 17:32 ` talebi.hossein at gmail dot com
@ 2014-01-05 20:18 ` dominiq at lps dot ens.fr
  2014-01-05 20:25 ` talebi.hossein at gmail dot com
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-01-05 20:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
After some trial and error steps I have been able to build an executable with
gfortran 4.8.2 on x86_64-apple-darwin13. Its output is

PERMIX 28 July 2013        
------------------------------

solver_init: Warning, Could not initialize an external solver; thus using
basicinternal PERMIX solver which is serial and cannot handle very big
problems.
 prx_read_input: reading the input ../verif/Test1/linearelastic_nonsolver.prx 
Adding a new PART_FEM
femcomm_init: maximum number of threads to use is 1                             
femmesh_input_elements_onmaster: Reading Elements finished
femmesh_input_nodes_onmaster2: Reading nodes finished
nonlinear_bonet : nonlinear_static analysis setup fornonlin_to_
part_fem_profile: profiling the part p1
part_fem_distrubute: Distributing the elements
femcomm_metis_partition: Doing the numbering of nodes and elements etc.
femcomm_metis_partition: Finished doing the numbering of nodes and elements
etc!
part_fem_profile: creating metis meshes.
part_fem_profile: creating element graphs.
femmesh_make_metis_graph: metis is not connected to Permix
part_fem_profile: Hisvar profiling.
part_fem_profile: Building element index.
part_fem_profile: Extra info allocation.
part_fem_profile: Surface profiling.
part_fem_profile: Initializing neighbors.
part_profile: Profiling done for all of the parts
initial_conditions_setup: Setting up initial conditions
part_number_dofs: numbering DOFs
part_number_dofs: Done, numbering DOFs
part_communication_setup: Setting up communication
part_communication_setup: setting up communication Done!
matrix_alloc_dynamic: Total DOFs of the sytem=30
initial_condition_apply: Applying initial conditions
modify_apply_initial_conditions: finished applying initial conditions! 
Dumping a paraview Down to disk at time step 0
nonlinear_bonet : nonlinear_static analysis started for nonlin_to_

nonlinear_bonet_execute: Load Step 1                                            
nonlinear_bonet_execute: Newton Iteration 1
solver_solve_serial: solving linear system of equations with solver BASIC
 IERR =        219
 2-NORM OF RESIDUAL =  0.7676777D-14
 MAX NORM OF RESIDUAL =  0.4575041D-14
nonlinear_bonet_execute: Line search iteration 2
 Step: 1 iteration: 1 residual: 0.328E-14 load factor: 1.0000
Dumping a paraview Down to disk at time step 1
Dumping a paraview Down to disk at time step 1
nonlinear_static: nonlinear_static Elastic analysis finished
   0.0000000000000000        0.0000000000000000        0.0000000000000000      
0.93525519689293113       -5.1386768226528851E-002   0.0000000000000000       
1.8704479398935832      -0.20905135365898059        0.0000000000000000       
2.8192502780015567      -0.47046146253562704        0.0000000000000000       
3.8025869994892636      -0.78100829707405917        0.0000000000000000       
0.0000000000000000        1.0038246696791657        0.0000000000000000       
1.0388142164215601       0.95227669875360443        0.0000000000000000       
2.0767135602228310       0.79822778503706648        0.0000000000000000       
3.0989617906167983       0.53888795060441641        0.0000000000000000       
4.1063496520944476       0.20190200013921400        0.0000000000000000       
0.0000000000000000        1.9766776015137038        0.0000000000000000       
1.1411034382808469        1.9253120702034390        0.0000000000000000       
2.2824067079693973        1.7732674736052365        0.0000000000000000       
3.4358274196452263        1.5248213416276999        0.0000000000000000       
4.5231752347833796        1.1721747001587519        0.0000000000000000     
permix_minimal_serial(54853,0x7fff770cb310) malloc: ***
mach_vm_map(size=18446744037562232832) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x10da38e42
#1  0x10da3960e
#2  0x7fff8d8705a9
Segmentation fault

Does it match what you get?

Trying to build with trunk yields the following ICE

../hisvar_class.f90: In function '__copy_hisvar_class_Ty_hisvar':
../hisvar_class.f90:208:0: internal compiler error: in
gfc_conv_string_parameter, at fortran/trans-expr.c:6919
    class(ty_hisvar) :: this
 ^


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] Segmentation fault on equalizing variables of a complex derived data type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (5 preceding siblings ...)
  2014-01-05 20:18 ` dominiq at lps dot ens.fr
@ 2014-01-05 20:25 ` talebi.hossein at gmail dot com
  2014-01-12 20:14 ` talebi.hossein at gmail dot com
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: talebi.hossein at gmail dot com @ 2014-01-05 20:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #8 from Hossein Talebi <talebi.hossein at gmail dot com> ---
Basically it is similar.  Below is the output and error message in Ubuntu x64
13.1 using GCC 4.8.1.   You get a little more information though.



PERMIX 28 July 2013       
------------------------------

solver_init: Warning, Could not initialize an external solver; thus using
basicinternal PERMIX solver which is serial and cannot handle very big
problems.
 prx_read_input: reading the input ../verif/Test1/linearelastic_nonsolver.prx
Adding a new PART_FEM
femcomm_init: maximum number of threads to use is 1                             
femmesh_input_elements_onmaster: Reading Elements finished
femmesh_input_nodes_onmaster2: Reading nodes finished
nonlinear_bonet : nonlinear_static analysis setup fornonlin_to_
part_fem_profile: profiling the part p1
part_fem_distrubute: Distributing the elements
femcomm_metis_partition: Doing the numbering of nodes and elements etc.
femcomm_metis_partition: Finished doing the numbering of nodes and elements
etc!
part_fem_profile: creating metis meshes.
part_fem_profile: creating element graphs.
femmesh_make_metis_graph: metis is not connected to Permix
part_fem_profile: Hisvar profiling.
part_fem_profile: Building element index.
part_fem_profile: Extra info allocation.
part_fem_profile: Surface profiling.
part_fem_profile: Initializing neighbors.
part_profile: Profiling done for all of the parts
initial_conditions_setup: Setting up initial conditions
part_number_dofs: numbering DOFs
part_number_dofs: Done, numbering DOFs
part_communication_setup: Setting up communication
part_communication_setup: setting up communication Done!
matrix_alloc_dynamic: Total DOFs of the sytem=30
initial_condition_apply: Applying initial conditions
modify_apply_initial_conditions: finished applying initial conditions!
Dumping a paraview Down to disk at time step 0
nonlinear_bonet : nonlinear_static analysis started for nonlin_to_

nonlinear_bonet_execute: Load Step 1                                            
nonlinear_bonet_execute: Newton Iteration 1
solver_solve_serial: solving linear system of equations with solver BASIC
 IERR =        219
 2-NORM OF RESIDUAL =  0.7676777D-14
 MAX NORM OF RESIDUAL =  0.4575041D-14
nonlinear_bonet_execute: Line search iteration 2
 Step: 1 iteration: 1 residual: 0.328E-14 load factor: 1.0000
Dumping a paraview Down to disk at time step 1
Dumping a paraview Down to disk at time step 1
nonlinear_static: nonlinear_static Elastic analysis finished
   0.0000000000000000        0.0000000000000000        0.0000000000000000      
0.93525519689293113       -5.1386768226528851E-002   0.0000000000000000       
1.8704479398935832      -0.20905135365898059        0.0000000000000000       
2.8192502780015567      -0.47046146253562704        0.0000000000000000       
3.8025869994892636      -0.78100829707405917        0.0000000000000000       
0.0000000000000000        1.0038246696791657        0.0000000000000000       
1.0388142164215601       0.95227669875360443        0.0000000000000000       
2.0767135602228310       0.79822778503706648        0.0000000000000000       
3.0989617906167983       0.53888795060441641        0.0000000000000000       
4.1063496520944476       0.20190200013921400        0.0000000000000000       
0.0000000000000000        1.9766776015137038        0.0000000000000000       
1.1411034382808469        1.9253120702034390        0.0000000000000000       
2.2824067079693973        1.7732674736052365        0.0000000000000000       
3.4358274196452263        1.5248213416276999        0.0000000000000000       
4.5231752347833796        1.1721747001587519        0.0000000000000000    

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7FF93F00E7D7
#1  0x7FF93F00EDDE
#2  0x7FF93E749FEF
#3  0x7FF93E863ED6
#4  0x7EE377 in permix at permix.f90:57 (discriminator 32)
Segmentation fault (core dumped)


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] Segmentation fault on equalizing variables of a complex derived data type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (6 preceding siblings ...)
  2014-01-05 20:25 ` talebi.hossein at gmail dot com
@ 2014-01-12 20:14 ` talebi.hossein at gmail dot com
  2014-01-12 20:19 ` talebi.hossein at gmail dot com
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: talebi.hossein at gmail dot com @ 2014-01-12 20:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #9 from Hossein Talebi <talebi.hossein at gmail dot com> ---
I looked at it in more details by overloading the automatic assignment (=) with
a self written one and I found the problem.  This is a minimalistic example
that the program crashes. Funny thing is that when I put MAX_PART_FEM=2, it
runs but not with any other number. I use ubuntu 13.1, GCC 4.8.1. 



module module1

   integer,parameter :: MAX_PART_FEM=32
   type ty_type3
      integer a,b
      integer, allocatable :: vec1(:)
   end type ty_type3

   type ptr_ty_part_fem
      type(ty_type3), allocatable :: OBJ
   end type ptr_ty_part_fem

   type ty_type2
      type(ptr_ty_part_fem)            :: parts_fem(MAX_PART_FEM)
      integer :: a2=1
   end type ty_type2

end module module1

program hello
   use module1
   implicit none

   type(ty_type2):: m2, m3
   m3=m2

   print *,m2%a2
end program


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] Segmentation fault on equalizing variables of a complex derived data type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (7 preceding siblings ...)
  2014-01-12 20:14 ` talebi.hossein at gmail dot com
@ 2014-01-12 20:19 ` talebi.hossein at gmail dot com
  2014-01-12 20:43 ` [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type janus at gcc dot gnu.org
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: talebi.hossein at gmail dot com @ 2014-01-12 20:19 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #10 from Hossein Talebi <talebi.hossein at gmail dot com> ---
I forgot to say, when I allocate the variables manually and then do assignment,
it works fine.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (8 preceding siblings ...)
  2014-01-12 20:19 ` talebi.hossein at gmail dot com
@ 2014-01-12 20:43 ` janus at gcc dot gnu.org
  2014-01-12 20:44 ` dominiq at lps dot ens.fr
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-12 20:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|WAITING                     |NEW
            Summary|Segmentation fault on       |[F03] Segfault on
                   |equalizing variables of a   |equalizing variables of a
                   |complex derived data type   |complex derived type

--- Comment #11 from janus at gcc dot gnu.org ---
Confirmed. Slightly reduced test case (fails at least with 4.6 up to trunk):

program hello
   implicit none

   type t3
      integer b
      integer, allocatable :: vec(:)
   end type

   type t2
      type(t3), allocatable :: obj
   end type

   type t1
      type(t2) :: parts
      integer :: a=1
   end type

   type(t1):: x, y

   y=x
end


The dump shows that the assignment is translated into:

  {
    void * restrict D.2321;
    integer(kind=8) D.2320;
    integer(kind=8) D.2319;
    integer(kind=8) D.2318;
    struct t1 D.2317;

    D.2317 = y;
    y = x;
    y.parts = x.parts;
    y.parts.obj = x.parts.obj;
    if ((void *) x.parts.obj.vec.data != 0B)
      {
        D.2318 = (x.parts.obj.vec.dim[0].ubound -
x.parts.obj.vec.dim[0].lbound) + 1;
        D.2319 = NON_LVALUE_EXPR <D.2318>;
        D.2320 = D.2319 * 4;
        D.2321 = (void * restrict) __builtin_malloc (MAX_EXPR <(unsigned long)
D.2320, 1>);
        y.parts.obj.vec.data = D.2321;
        __builtin_memcpy ((integer(kind=4)[0:] * restrict)
y.parts.obj.vec.data, (integer(kind=4)[0:] * restrict) x.parts.obj.vec.data,
(unsigned long) (D.2319 * 4));
      }
    else
      {
        y.parts.obj.vec.data = 0B;
      }
    if (D.2317.parts.obj != 0B)
      {
        if (D.2317.parts.obj->vec.data != 0B)
          {
            __builtin_free ((void *) D.2317.parts.obj->vec.data);
          }
        D.2317.parts.obj->vec.data = 0B;
        __builtin_free ((void *) D.2317.parts.obj);
      }
    D.2317.parts.obj = 0B;
  }


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (9 preceding siblings ...)
  2014-01-12 20:43 ` [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type janus at gcc dot gnu.org
@ 2014-01-12 20:44 ` dominiq at lps dot ens.fr
  2014-01-12 20:46 ` dominiq at lps dot ens.fr
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-01-12 20:44 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #12 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
For the test in comment 9, valgrind gives

==30542== Conditional jump or move depends on uninitialised value(s)
==30542==    at 0x100000D3C: MAIN__ (pr59678.f90:25)
==30542==    by 0x100000E95: main (pr59678.f90:21)
==30542== 
==30542== Conditional jump or move depends on uninitialised value(s)
==30542==    at 0x7FFFFFE007B0: ???
==30542==    by 0x100000DCB: MAIN__ (pr59678.f90:25)
==30542==    by 0x100000E95: main (pr59678.f90:21)
==30542== 
==30542== Conditional jump or move depends on uninitialised value(s)
==30542==    at 0x7FFFFFE007B6: ???
==30542==    by 0x100000DCB: MAIN__ (pr59678.f90:25)
==30542==    by 0x100000E95: main (pr59678.f90:21)
==30542== 
==30542== Conditional jump or move depends on uninitialised value(s)
==30542==    at 0x7FFFFFE007F3: ???
==30542==    by 0x100000DCB: MAIN__ (pr59678.f90:25)
==30542==    by 0x100000E95: main (pr59678.f90:21)
==30542== 
==30542== Use of uninitialised value of size 8
==30542==    at 0x7FFFFFE012B1: ???
==30542==    by 0x7FFFFFE00879: ???
==30542==    by 0x100000DCB: MAIN__ (pr59678.f90:25)
==30542==    by 0x100000E95: main (pr59678.f90:21)
==30542== 
==30542== Invalid read of size 1
==30542==    at 0x7FFFFFE012B1: ???
==30542==    by 0x7FFFFFE00879: ???
==30542==    by 0x100000DCB: MAIN__ (pr59678.f90:25)
==30542==    by 0x100000E95: main (pr59678.f90:21)
==30542==  Address 0xe41 is not stack'd, malloc'd or (recently) free'd

I am not sure that the code is valid: allocatables not allocated.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (10 preceding siblings ...)
  2014-01-12 20:44 ` dominiq at lps dot ens.fr
@ 2014-01-12 20:46 ` dominiq at lps dot ens.fr
  2014-01-12 20:54 ` janus at gcc dot gnu.org
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-01-12 20:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #13 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
For the test in comment 11 valgrind gives

==41825== Invalid read of size 4
==41825==    at 0x7FFFFFE007BF: ???
==41825==    by 0x100000DAF: MAIN__ (pr59678_1.f90:20)
==41825==    by 0x100000ED4: main (pr59678_1.f90:21)
==41825==  Address 0x1 is not stack'd, malloc'd or (recently) free'd


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (11 preceding siblings ...)
  2014-01-12 20:46 ` dominiq at lps dot ens.fr
@ 2014-01-12 20:54 ` janus at gcc dot gnu.org
  2014-04-20 19:52 ` talebi.hossein at gmail dot com
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-12 20:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #14 from janus at gcc dot gnu.org ---
(In reply to janus from comment #11)
> The dump shows that the assignment is translated into:
> 
>   {
>     void * restrict D.2321;
>     integer(kind=8) D.2320;
>     integer(kind=8) D.2319;
>     integer(kind=8) D.2318;
>     struct t1 D.2317;
> 
>     D.2317 = y;
>     y = x;
>     y.parts = x.parts;
>     y.parts.obj = x.parts.obj;

Up to here the dump is fine, but it the next line things start to go wrong:

>     if ((void *) x.parts.obj.vec.data != 0B)

We fail to check if obj is allocated.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (12 preceding siblings ...)
  2014-01-12 20:54 ` janus at gcc dot gnu.org
@ 2014-04-20 19:52 ` talebi.hossein at gmail dot com
  2015-04-18 11:31 ` vehre at gcc dot gnu.org
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: talebi.hossein at gmail dot com @ 2014-04-20 19:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #15 from Hossein Talebi <talebi.hossein at gmail dot com> ---
Hi, will this bug be fixed anytime soon or is it fixed already in GCC4.9?


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (13 preceding siblings ...)
  2014-04-20 19:52 ` talebi.hossein at gmail dot com
@ 2015-04-18 11:31 ` vehre at gcc dot gnu.org
  2015-04-27 17:34 ` vehre at gcc dot gnu.org
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-04-18 11:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

vehre at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING

--- Comment #16 from vehre at gcc dot gnu.org ---
A patch is available at:

https://gcc.gnu.org/ml/fortran/2015-04/msg00061.html

awaiting review.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (14 preceding siblings ...)
  2015-04-18 11:31 ` vehre at gcc dot gnu.org
@ 2015-04-27 17:34 ` vehre at gcc dot gnu.org
  2015-05-05  9:03 ` vehre at gcc dot gnu.org
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-04-27 17:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #17 from vehre at gcc dot gnu.org ---
Author: vehre
Date: Mon Apr 27 17:34:11 2015
New Revision: 222477

URL: https://gcc.gnu.org/viewcvs?rev=222477&root=gcc&view=rev
Log:
gcc/fortran
2015-04-27  Andre Vehreschild  <vehre@gmx.de>

        PR fortran/59678
        PR fortran/65841
        * trans-array.c (duplicate_allocatable): Fixed deep copy of
        allocatable components, which are liable for copy only, when
        they are allocated.
        (gfc_duplicate_allocatable): Add deep-copy code into if
        component allocated block. Needed interface change for that.
        (gfc_copy_allocatable_data): Supplying NULL_TREE for code to
        add into if-block for checking whether a component was
        allocated.
        (gfc_duplicate_allocatable_nocopy): Likewise.
        (structure_alloc_comps): Likewise.
        * trans-array.h: Likewise.
        * trans-expr.c (gfc_trans_alloc_subarray_assign): Likewise.
        * trans-openmp.c (gfc_walk_alloc_comps): Likewise.

gcc/testsuite
2015-04-27  Andre Vehreschild  <vehre@gmx.de>

        PR fortran/59678
        PR fortran/65841
        * gfortran.dg/alloc_comp_deep_copy_1.f03: New test.
        * gfortran.dg/alloc_comp_deep_copy_2.f03: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_1.f03
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_2.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-array.h
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-openmp.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (15 preceding siblings ...)
  2015-04-27 17:34 ` vehre at gcc dot gnu.org
@ 2015-05-05  9:03 ` vehre at gcc dot gnu.org
  2015-05-05 23:06 ` talebi.hossein at gmail dot com
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-05-05  9:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

vehre at gcc dot gnu.org changed:

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

--- Comment #18 from vehre at gcc dot gnu.org ---
Resolved with commit r222477. No objections so far, closing.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (16 preceding siblings ...)
  2015-05-05  9:03 ` vehre at gcc dot gnu.org
@ 2015-05-05 23:06 ` talebi.hossein at gmail dot com
  2015-05-06  8:09 ` vehre at gcc dot gnu.org
  2015-10-18 15:01 ` mikael at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: talebi.hossein at gmail dot com @ 2015-05-05 23:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #19 from Hossein Talebi <talebi.hossein at gmail dot com> ---
Hi,

This patch goes to Gfortran 4.8 or the current version? Thank you.

Cheers
H.

On Tue, May 5, 2015 at 7:03 PM, vehre at gcc dot gnu.org <
gcc-bugzilla@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678
>
> vehre at gcc dot gnu.org changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>              Status|WAITING                     |RESOLVED
>          Resolution|---                         |FIXED
>
> --- Comment #18 from vehre at gcc dot gnu.org ---
> Resolved with commit r222477. No objections so far, closing.
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You reported the bug.
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (17 preceding siblings ...)
  2015-05-05 23:06 ` talebi.hossein at gmail dot com
@ 2015-05-06  8:09 ` vehre at gcc dot gnu.org
  2015-10-18 15:01 ` mikael at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-05-06  8:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #20 from vehre at gcc dot gnu.org ---
This patch is for trunk, aka 6.0.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type
  2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
                   ` (18 preceding siblings ...)
  2015-05-06  8:09 ` vehre at gcc dot gnu.org
@ 2015-10-18 15:01 ` mikael at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-10-18 15:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #21 from Mikael Morin <mikael at gcc dot gnu.org> ---
Author: mikael
Date: Sun Oct 18 15:01:03 2015
New Revision: 228945

URL: https://gcc.gnu.org/viewcvs?rev=228945&root=gcc&view=rev
Log:
        PR fortran/67721
        PR fortran/67818
        Backport from mainline r222477:

        2015-04-27  Andre Vehreschild  <vehre@gmx.de>

        PR fortran/59678
        PR fortran/65841
gcc/fortran/
        * trans-array.c (duplicate_allocatable): Fixed deep copy of
        allocatable components, which are liable for copy only, when
        they are allocated.
        (gfc_duplicate_allocatable): Add deep-copy code into if
        component allocated block. Needed interface change for that.
        (gfc_copy_allocatable_data): Supplying NULL_TREE for code to
        add into if-block for checking whether a component was
        allocated.
        (gfc_duplicate_allocatable_nocopy): Likewise.
        (structure_alloc_comps): Likewise.
        * trans-array.h: Likewise.
        * trans-expr.c (gfc_trans_alloc_subarray_assign): Likewise.
        * trans-openmp.c (gfc_walk_alloc_comps): Likewise.
gcc/testsuite/
        * gfortran.dg/alloc_comp_deep_copy_1.f03: New test.
        * gfortran.dg/alloc_comp_deep_copy_2.f03: New test.


Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_1.f03
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_2.f03
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/trans-array.c
    branches/gcc-5-branch/gcc/fortran/trans-array.h
    branches/gcc-5-branch/gcc/fortran/trans-expr.c
    branches/gcc-5-branch/gcc/fortran/trans-openmp.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2015-10-18 15:01 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-04 23:38 [Bug fortran/59678] New: Segmentation fault on equalizing variables of a complex derived data type talebi.hossein at gmail dot com
2014-01-05 12:53 ` [Bug fortran/59678] " talebi.hossein at gmail dot com
2014-01-05 13:17 ` janus at gcc dot gnu.org
2014-01-05 14:30 ` talebi.hossein at gmail dot com
2014-01-05 15:45 ` dominiq at lps dot ens.fr
2014-01-05 17:32 ` talebi.hossein at gmail dot com
2014-01-05 20:18 ` dominiq at lps dot ens.fr
2014-01-05 20:25 ` talebi.hossein at gmail dot com
2014-01-12 20:14 ` talebi.hossein at gmail dot com
2014-01-12 20:19 ` talebi.hossein at gmail dot com
2014-01-12 20:43 ` [Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type janus at gcc dot gnu.org
2014-01-12 20:44 ` dominiq at lps dot ens.fr
2014-01-12 20:46 ` dominiq at lps dot ens.fr
2014-01-12 20:54 ` janus at gcc dot gnu.org
2014-04-20 19:52 ` talebi.hossein at gmail dot com
2015-04-18 11:31 ` vehre at gcc dot gnu.org
2015-04-27 17:34 ` vehre at gcc dot gnu.org
2015-05-05  9:03 ` vehre at gcc dot gnu.org
2015-05-05 23:06 ` talebi.hossein at gmail dot com
2015-05-06  8:09 ` vehre at gcc dot gnu.org
2015-10-18 15:01 ` mikael at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).