Running valgrind on gfortran (or rather f951) -fsyntax-only shows the following leaks. (This PR assumed that my patch http://gcc.gnu.org/ml/fortran/2012-08/msg00180.html has been applied plus a follow up for module.c's mio_symbol which removes the "sym->refs++".) With Polyhedron 2005's channel.f90 (and rnflow.f90): by 0x606B33: gfc_get_array_ss(gfc_ss*, gfc_expr*, int, gfc_ss_type) (trans-array.c:561) by 0x612F00: gfc_walk_expr(gfc_expr*) (trans-array.c:8787) by 0x639F98: gfc_trans_arrayfunc_assign(gfc_expr*, gfc_expr*) (trans-expr.c:6749) by 0x63B911: gfc_trans_assignment(gfc_expr*, gfc_expr*, bool, bool) (trans-expr.c:7438) With Polyhedron 2005's mdbx.f90: by 0x57D7BF: gfc_get_expr() (expr.c:49) by 0x57E123: gfc_copy_expr(gfc_expr*) (expr.c:272) by 0x5C63EA: gfc_match_rvalue(gfc_expr**) (primary.c:2788) by 0x56D3A2: match_data_constant(gfc_expr**) (decl.c:354) With Polyhedron 2005's nf.f90: by 0x57E1807: __gmpz_init (in /usr/lib64/libgmp.so.10.0.5) by 0x57D9EB: gfc_get_constant_expr(bt, int, locus*) (expr.c:161) by 0x57DB17: gfc_get_int_expr(int, locus*, int) (expr.c:217) by 0x5F592C: _ZL24check_section_vs_sectionP13gfc_array_refS0_i.part.4 (dependency.c:1213) by 0x5F6C47: gfc_dep_resolver(gfc_ref*, gfc_ref*, gfc_reverse*) (dependency.c:1155) by 0x60C585: gfc_conv_resolve_dependencies(gfc_loopinfo*, gfc_ss*, gfc_ss*) (trans-array.c:4309) by 0x63A891: gfc_trans_assignment_1(gfc_expr*, gfc_expr*, bool, bool) (trans-expr.c:7238) With Polyhedron 2005's capacita.f90: Several. I think the only new one is: by 0x5EF33E: gfc_get_namespace(gfc_namespace*, int) (symbol.c:2325) by 0x5F0F09: gfc_copy_formal_args_intr(gfc_symbol*, gfc_intrinsic_sym*) (symbol.c:4161) by 0x63C50C: gfc_get_symbol_for_expr(gfc_expr*) (trans-intrinsic.c:2334) by 0x64A0EB: gfc_conv_intrinsic_function(gfc_se*, gfc_expr*) (trans-intrinsic.c:4525) With Polyhedron 2005's capacita.f90 (and some more): by 0x57D9EB: gfc_get_constant_expr(bt, int, locus*) (expr.c:161) by 0x57DB17: gfc_get_int_expr(int, locus*, int) (expr.c:217) by 0x55C016: gfc_simplify_iterator_var(gfc_expr*) (array.c:1445) by 0x5826E4: gfc_simplify_expr(gfc_expr*, int) (expr.c:1894) by 0x56A394: gfc_assign_data_value(gfc_expr*, gfc_expr*, __mpz_struct*, __mpz_struct (*) [1]) (data.c:61) With gfortran.dg/proc_ptr_result_1.f90: by 0x5EF6E7: gfc_new_symbol(char const*, gfc_namespace*) (symbol.c:2569) by 0x5716DA: gfc_match_procedure() (decl.c:4916) ---- and ---- by 0x5EF6E7: gfc_new_symbol(char const*, gfc_namespace*) (symbol.c:2569) by 0x5EFA62: gfc_get_sym_tree(char const*, gfc_namespace*, gfc_symtree**, bool) (symbol.c:2753) by 0x56B76C: find_special(char const*, gfc_symbol**, bool) (decl.c:802) by 0x574F28: attr_decl() (decl.c:6174) ---- and ---- by 0x5EF33E: gfc_get_namespace(gfc_namespace*, int) (symbol.c:2325) by 0x5F0D3C: gfc_copy_formal_args(gfc_symbol*, gfc_symbol*, ifsrc) (symbol.c:4104) by 0x5F0E30: gfc_copy_formal_args(gfc_symbol*, gfc_symbol*, ifsrc) (symbol.c:4117) by 0x5D7A5E: resolve_procedure_interface(gfc_symbol*) (resolve.c:228) by 0x5CC420: resolve_symbol(gfc_symbol*) (resolve.c:12581) ---- and ---- by 0x5EF33E: gfc_get_namespace(gfc_namespace*, int) (symbol.c:2325) by 0x5B4040: load_needed(pointer_info*) (module.c:4375) by 0x5B4DCB: read_module() (module.c:4773) ---- and ---- the gfc_match_rvalue issue of mdbx.f90. Also leaking, but I lost the overview whether those are already covered: doduc.f90. (I also haven't tested all of Polyhedron.)
Author: burnus Date: Mon Aug 27 14:42:50 2012 New Revision: 190713 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190713 Log: 2012-08-27 Tobias Burnus <burnus@net-b.de> PR fortran/54384 * trans-expr.c (gfc_trans_arrayfunc_assign): Free se.ss and loop. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-expr.c
The patch of comment 0 fixed the gfc_trans_assignment->gfc_trans_arrayfunc_assign issue of channel.f90 and rnflow.f90. The other issues remain.
Author: burnus Date: Mon Aug 27 18:47:57 2012 New Revision: 190728 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190728 Log: 2012-08-27 Tobias Burnus <burnus@net-b.de> PR fortran/54384 * dependency.c (check_section_vs_section): Use gfc_free_expr instead of free. * trans-intrinsic.c (conv_generic_with_optional_char_arg): Use gfc_free_symbol instead of free. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/dependency.c trunk/gcc/fortran/trans-intrinsic.c
(In reply to comment #0) > With Polyhedron 2005's nf.f90: > With Polyhedron 2005's capacita.f90: Those are fixed by comment 3 > With Polyhedron 2005's capacita.f90 (and some more): I think that's aermod.f90 not capacita.f90 - the latter has no leaks any more. > With Polyhedron 2005's mdbx.f90: > by 0x57D7BF: gfc_get_expr() (expr.c:49) > by 0x57E123: gfc_copy_expr(gfc_expr*) (expr.c:272) > by 0x5C63EA: gfc_match_rvalue(gfc_expr**) (primary.c:2788) > by 0x56D3A2: match_data_constant(gfc_expr**) (decl.c:354) Reduced test case: DIMENSION cmul(3,7) PARAMETER (HALF=0.5D0,ONE=1.D0,TWO=2.D0,FOUR=4.D0,TWELVE=12.D0) PARAMETER (SQRT2=1.41421356237310D0,SQRT3=1.73205080756888D0, & & SQRT8=TWO*SQRT2,SQ8BY3=SQRT8/SQRT3,SQ4BY3=TWO/SQRT3, & & SQ16B3=FOUR/SQRT3) DATA cmul/SQRT2 , SQRT2 , SQRT2 , ONE , ONE , SQRT8 , ONE , & & SQRT2 , TWO , ONE , SQRT3 , SQ8BY3 , ONE , SQRT3 , SQ8BY3 , & & ONE , ONE , SQRT8 , SQ4BY3 , SQ4BY3 , SQ16B3/ END Not fixing this issue, but I think still required: --- a/gcc/fortran/data.c +++ b/gcc/fortran/data.c @@ -142,2 +142,4 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts, gfc_extract_int (end_expr, &end); + gfc_free_expr (start_expr); + gfc_free_expr (end_expr); } > Also leaking, but I lost the overview whether those are already covered: > doduc.f90. Others still not tested, but doduc.f90 fails with: by 0x63624D: _ZL22gfc_conv_function_exprP6gfc_seP8gfc_expr.part.22 (trans-expr.c:4999) by 0x63951B: gfc_conv_expr_op(gfc_se*, gfc_expr*) (trans-expr.c:2158) by 0x63951B: gfc_conv_expr_op(gfc_se*, gfc_expr*) (trans-expr.c:2158) by 0x638553: gfc_conv_expr_val(gfc_se*, gfc_expr*) (trans-expr.c:5851) by 0x638620: gfc_conv_unary_op(tree_code, gfc_se*, gfc_expr*) (trans-expr.c:1535) by 0x639AFF: gfc_conv_expr_op(gfc_se*, gfc_expr*) (trans-expr.c:2031) by 0x6394F6: gfc_conv_expr_op(gfc_se*, gfc_expr*) (trans-expr.c:2153) by 0x63C163: gfc_trans_assignment_1(gfc_expr*, gfc_expr*, bool, bool) (trans-expr.c:7278)
Author: burnus Date: Mon Aug 27 20:51:52 2012 New Revision: 190731 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190731 Log: 2012-08-27 Tobias Burnus <burnus@net-b.de> PR fortran/54384 * resolve.c (gfc_resolve_character_operator): Free temporary variables. * trans-expr.c (gfc_conv_statement_function): Ditto. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c trunk/gcc/fortran/trans-expr.c
(In reply to comment #4) > Others still not tested, but doduc.f90 fails with: This one (and hence all of doduc.f90) - and some of the failures in aermod.f90 are fixed with comment 5. TODO: * match_data_constant (mbdx.f90, comment 5) * gfortran.dg/proc_ptr_result_1.f90 (comment 0) * aermod.f90: by 0x5F0EC7: gfc_new_symbol(char const*, gfc_namespace*) (symbol.c:2569) by 0x5F1242: gfc_get_sym_tree(char const*, gfc_namespace*, gfc_symtree**, bool) (symbol.c:2753) by 0x5F12C3: gfc_get_symbol(char const*, gfc_namespace*, gfc_symbol**) (symbol.c:2807) by 0x57184A: gfc_match_formal_arglist(gfc_symbol*, int, int) (decl.c:4462) by 0x573E65: gfc_match_subroutine() (decl.c:5655) -- and -- by 0x5F0B1E: gfc_get_namespace(gfc_namespace*, int) (symbol.c:2325) by 0x5C064E: parse_spec(gfc_statement) (parse.c:2390) by 0x5C2318: parse_progunit(gfc_statement) (parse.c:4131) by 0x5C3243: gfc_parse_file() (parse.c:4579) -- and -- by 0x57F00F: gfc_get_expr() (expr.c:49) by 0x57F973: gfc_copy_expr(gfc_expr*) (expr.c:272) by 0x56BBD4: gfc_assign_data_value(gfc_expr*, gfc_expr*, __mpz_struct*, __mpz_struct (*) [1]) (data.c:60) by 0x5D86DB: traverse_data_var(gfc_data_variable*, locus*) (resolve.c:13341) by 0x5D8C0D: traverse_data_var(gfc_data_variable*, locus*) (resolve.c:13426) by 0x5D9E83: resolve_types(gfc_namespace*) (resolve.c:13525) -- and -- some more * gfortran.dg/g77/cpp6.f: by 0x5DE174: preprocessor_line(unsigned int*) (scanner.c:1803) by 0x5DE6EA: load_file(char const*, char const*, bool) (scanner.c:2038) by 0x5E0422: gfc_new_file() (scanner.c:2106)
Author: burnus Date: Tue Aug 28 05:35:15 2012 New Revision: 190738 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190738 Log: 2012-08-28 Tobias Burnus <burnus@net-b.de> PR fortran/54384 * symbol.c (gfc_copy_formal_args): Set also sym->formal_ns. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/symbol.c
(In reply to comment #0) > With gfortran.dg/proc_ptr_result_1.f90: > by 0x5F0D3C: gfc_copy_formal_args(gfc_symbol*, gfc_symbol*, ifsrc) That issue is now fixed by comment 7 - the others remain.
Author: burnus Date: Tue Aug 28 14:49:15 2012 New Revision: 190751 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190751 Log: 2012-08-28 Tobias Burnus <burnus@net-b.de> PR fortran/54384 * decl.c (match_data_constant): Add missing gfc_free_expr. (top_val_list): Remove always-true condition. * data.c (get_array_index, create_character_initializer): Free temporary expressions. (gfc_assign_data_value): Free expression when aborting. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/data.c trunk/gcc/fortran/decl.c
(In reply to comment #6) > * match_data_constant (mbdx.f90, comment 5) > * aermod.f90: > by 0x5D8C0D: traverse_data_var(gfc_data_variable*, locus*) (resolve.c:13426) These two are now fixed. (comment 9) TODO: * aermod.f90 (cf. comment 6) - parse_spec -> gfc_match_subroutine -> gfc_match_formal_arglist - parse_spec -> gfc_get_namespace (also: gas_dyn.f90 and test_fpu.f90) those are the only gfortran valgrind-reported leaks left for Polyhedron 2005. * gfortran.dg/g77/cpp6.f's preprocessor_line, cf. comment 6 * gfortran.dg/proc_ptr_result_1.f90 (comment 0) with - ...-> match_level_3 -> ... -> gfc_match_rvalue -> gfc_new_symbol - read_module -> load_needed -> gfc_get_namespace - gfc_match_procedure -> gfc_new_symbol - gfc_match_intrinsic -> gfc_new_symbol [Plus more valgrind runs to find more leaks.]
Considering the number of commits, this PR can probably marked as confirmed.
This PR is concerned with compile-time leaks, not run-time leaks, therefore it should not block PR 86754, but rather PR 68800.