From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10951 invoked by alias); 28 May 2011 15:12:44 -0000 Received: (qmail 10941 invoked by uid 22791); 28 May 2011 15:12:43 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_BV X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 28 May 2011 15:12:29 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/47601] [OOP] Internal Error: mio_component_ref(): Component not found X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: janus at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sat, 28 May 2011 15:21:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg02846.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47601 --- Comment #20 from Tobias Burnus 2011-05-28 15:12:26 UTC --- Valgrind shows: ==9238== Invalid read of size 8 ==9238== at 0x55AFD9: gfc_use_derived (symbol.c:1942) ==9238== by 0x55B126: gfc_find_component (symbol.c:2002) ==9238== by 0x55B24A: gfc_find_component (symbol.c:2015) ==9238== by 0x520B40: mio_ref (module.c:2359) In gfc_use_derived, sym == NULL - thus, it is not surprising that sym->components gives an ICE. The bug seems to be in gfc_find_component where the order of sym == NULL and gfc_use_derived seems to be reverted: --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -2000,9 +2000,9 @@ gfc_find_component (gfc_symbol *sym, const char *name, return NULL; - sym = gfc_use_derived (sym); - if (sym == NULL) return NULL; + sym = gfc_use_derived (sym); + for (p = sym->components; p; p = p->next) if (strcmp (p->name, name) == 0) * * * If one combines both patches, all reduced test cases work (comment 8, comment 11 and comment 13) and also the segfault is gone. However, in the last file of the compilation series, one now gets: gyre_lanr.f90:6.19: use gyre_lanr_bvp 1 Interner Fehler bei (1): mio_component_ref(): Component not found * * * Note: For that ICE, the flag -std=f2003 is crucial. If I compile gyre_lanr_bvp.f90 without it, I do not get an ICE. I have not checked whether that's by chance (memory layout or similar).