[Bug fortran/32795] allocatable components are nullified prematurely

burnus at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Aug 1 18:39:00 GMT 2007



------- Comment #5 from burnus at gcc dot gnu dot org  2007-08-01 18:39 -------
> Could somebody test the patch below, please?
Build (/= bootstrapped) and check-gfortran'ed (-m64) on x86-64-Linux.

I get an ICE (segmentation fault) for gfortran.dg/derived_comp_array_ref_1.f90:
==26501== Invalid read of size 8
==26501==    at 0x482610: structure_alloc_comps (trans-array.c:5158)
==26501==    by 0x4AB106: generate_loop_for_temp_to_lhs (trans-stmt.c:1737)

Analogously for gfortran.dg/forall_char_dependencies_1.f90 except that valgrind
does not show an error. gdb shows:

Program received signal SIGSEGV, Segmentation fault.
structure_alloc_comps (der_type=0x0, decl=0x2abe5b14b000, dest=0x0, rank=0,
purpose=1)    at trans-array.c:5158
5158      for (c = der_type->components; c; c = c->next)
#1  0x00000000004ab107 in generate_loop_for_temp_to_lhs (expr=0xf57ff0,
tmp1=0x2abe5b129f20, count3=0x0,
    count1=0x2abe5b129e70, wheremask=0x0, invert=0 '\0') at trans-stmt.c:1737


The problem is that  expr->ts.derived  == NULL in
+       falselhs = gfc_deallocate_alloc_comp (expr->ts.derived, falselhs, 0);

and that gfc_deallocate_alloc_comp simply accesses expr->ts.derived->component
without ever checking if expr->ts.derived is NULL.


-- 


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



More information about the Gcc-bugs mailing list