------- Comment #6 from dfranke at gcc dot gnu dot org 2008-01-23 23:43 ------- integer :: c ! anything, makes block data invalid block data bd common d ! 'd' undefined, new symbol generated that needs to be undone end block data bd end
In the code above, the newly generated symbol for 'd' is plugged into the namespace hooks for commons (here, gfc_current_ns->blank_common). In gfc_undo_symbols(), the symbol itself is removed, but the namespace hooks are left untouched. Hence, while traversing the namespace, gfortran tries to resolve a dead symbol resulting in valgrind errors as ==23032== Invalid read of size 4 ==23032== at 0x80A171F: resolve_common_vars (resolve.c:658) ==23032== by 0x4600BC7: ??? ==23032== Address 0x42320d4 is 76 bytes inside a block of size 288 free'd ==23032== at 0x402248F: free (vg_replace_malloc.c:323) ==23032== by 0x80B9C1C: gfc_undo_symbols (symbol.c:2591) I think we need to check if the symbol was added to the COMMON-structures (sym->attr.in_common == 1) and, if yes, remove it as well. If no one beats me to it, I will try to see if I'm right within the next days :) -- dfranke at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dfranke at gcc dot gnu dot | |org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34858