This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
f951 segfaults for gfortran.dg/initialization_1.f90
- From: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 15 Apr 2008 09:27:34 +0900 (JST)
- Subject: f951 segfaults for gfortran.dg/initialization_1.f90
Hi,
I've got the failures on sh4-unknown-linux-gnu for
gfortran.dg/initialization_1.f90:
http://gcc.gnu.org/ml/gcc-testresults/2008-04/msg01012.html
Although these failures are not seen on i686, it failed if
f951 was run under gdb:
$ gdb ./i686-gcc-orig/gcc/f951
GNU gdb Red Hat Linux (6.6-45.fc8rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) r trunk/gcc/testsuite/gfortran.dg/initialization_1.f90 -pedantic-errors -o initialization_1.s
Starting program: i686-gcc-orig/gcc/f951 trunk/gcc/testsuite/gfortran.dg/initialization_1.f90 -pedantic-errors -o initialization_1.s
Program received signal SIGSEGV, Segmentation fault.
0x087cdf7c in splay_tree_delete (sp=0x38725f)
at ../trunk/libiberty/splay-tree.c:286
286 splay_tree_delete_helper (sp, sp->root);
It seems that scalarize_intrinsic_call calls gfc_free_expr for
the uninitialized expr variable. The appended patch works for me,
though I'm not sure how to fix this correctly. Could gfortran
experts take a look?
Regards,
kaz
--
* expr.c (scalarize_intrinsic_call): Initialize expr variable.
Don't call gfc_free_expr for null expr.
--- ORIG/trunk/gcc/fortran/expr.c 2008-04-14 10:52:56.000000000 +0900
+++ LOCAL/trunk/gcc/fortran/expr.c 2008-04-14 10:53:15.000000000 +0900
@@ -1711,6 +1711,7 @@ scalarize_intrinsic_call (gfc_expr *e)
expression carries the type information and that the first arg
that is an array expression carries all the shape information.*/
n = array_arg = 0;
+ expr = NULL;
a = old->value.function.actual;
for (; a; a = a->next)
{
@@ -1824,7 +1825,8 @@ compliance:
gfc_error_now ("elemental function arguments at %C are not compliant");
cleanup:
- gfc_free_expr (expr);
+ if (expr)
+ gfc_free_expr (expr);
gfc_free_expr (old);
return FAILURE;
}