From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97892 invoked by alias); 29 Jul 2015 18:36:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 97871 invoked by uid 89); 29 Jul 2015 18:36:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: smtp22.services.sfr.fr Received: from smtp22.services.sfr.fr (HELO smtp22.services.sfr.fr) (93.17.128.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 29 Jul 2015 18:36:16 +0000 Received: from filter.sfr.fr (localhost [86.72.15.111]) by msfrf2202.sfr.fr (SMTP Server) with ESMTP id 5DD697000747; Wed, 29 Jul 2015 20:36:13 +0200 (CEST) Authentication-Results: sfrmc.priv.atos.fr; dkim=none (no signature); dkim-adsp=none (no policy) header.from=mikael.morin@sfr.fr Received: from tolstoi.localhost (111.15.72.86.rev.sfr.net [86.72.15.111]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by msfrf2202.sfr.fr (SMTP Server) with ESMTP id 7D4DB7000750; Wed, 29 Jul 2015 20:36:12 +0200 (CEST) X-SFR-UUID: 20150729183612513.7D4DB7000750@msfrf2202.sfr.fr From: Mikael Morin Subject: Re: patch fortran, pr 59746, internal compiler error : segmentation fault To: Tobias Burnus , jimmie.davis@l-3com.com, gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org References: <531CA574.2050900@sfr.fr> <531CD1A3.6070303@sfr.fr> <5322208C.1010002@sfr.fr> <535D50B8.3070801@net-b.de> Message-ID: <55B91D0D.2020606@sfr.fr> Date: Wed, 29 Jul 2015 19:18:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <535D50B8.3070801@net-b.de> Content-Type: multipart/mixed; boundary=------------090301000003080501040400 X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg02497.txt.bz2 This is a multi-part message in MIME format. --------------090301000003080501040400 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 300 Hello, I'm unburrying the patch from the thread starting at: https://gcc.gnu.org/ml/gcc-patches/2014-03/msg00439.html I provide the patch in two flavors read-only (without whitespace changes) and write-only (with them). This has been tested on x86_64-unknown-linux-gnu. OK for trunk? Mikael --------------090301000003080501040400 Content-Type: text/plain; charset=UTF-8; name="pr59746_4.CL" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="pr59746_4.CL" Content-length: 415 MjAxNS0wNy0yOSAgQnVkIERhdmlzICA8am1kYXZpc0BsaW5rLmNvbT4KCSAg ICBNaWthZWwgTW9yaW4gIDxtaWthZWxAZ2NjLmdudS5vcmc+CgoJUFIgZm9y dHJhbi81OTc0NgoJKiBzeW1ib2wuYyAoZ2ZjX3Jlc3RvcmVfbGFzdF91bmRv X2NoZWNrcG9pbnQpOiBEZWxldGUgYSBjb21tb24gYmxvY2sKCXN5bWJvbCBp ZiBpdCB3YXMgcHV0IGluIHRoZSBsaXN0LgoKMjAxNS0wNy0yOSAgQnVkIERh dmlzICA8am1kYXZpc0BsaW5rLmNvbT4KCglQUiBmb3J0cmFuLzU5NzQ2Cgkq IGdmb3J0cmFuLmRnL2NvbW1vbl8yMi5mOTA6IE5ldy4KCg== --------------090301000003080501040400 Content-Type: text/x-patch; name="pr59746_4_cb.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr59746_4_cb.diff" Content-length: 3113 *** /tmp/ro4P6U_symbol.c 2015-07-29 20:08:48.675970662 +0200 --- gcc/fortran/symbol.c 2015-07-29 19:48:25.580979685 +0200 *************** gfc_restore_last_undo_checkpoint (void) *** 3168,3177 **** FOR_EACH_VEC_ELT (latest_undo_chgset->syms, i, p) { ! if (p->gfc_new) ! { ! /* Symbol was new. */ ! if (p->attr.in_common && p->common_block && p->common_block->head) { /* If the symbol was added to any common block, it needs to be removed to stop the resolver looking --- 3168,3177 ---- FOR_EACH_VEC_ELT (latest_undo_chgset->syms, i, p) { ! /* Symbol was new. Or was old and just put in common */ ! if ((p->gfc_new ! || (p->attr.in_common && !p->old_symbol->attr.in_common )) ! && p->attr.in_common && p->common_block && p->common_block->head) { /* If the symbol was added to any common block, it needs to be removed to stop the resolver looking *************** gfc_restore_last_undo_checkpoint (void) *** 3206,3216 **** } gcc_assert(cparent->common_next == p); - cparent->common_next = csym->common_next; } } ! /* The derived type is saved in the symtree with the first letter capitalized; the all lower-case version to the derived type contains its associated generic function. */ --- 3206,3216 ---- } gcc_assert(cparent->common_next == p); cparent->common_next = csym->common_next; } } ! if (p->gfc_new) ! { /* The derived type is saved in the symtree with the first letter capitalized; the all lower-case version to the derived type contains its associated generic function. */ *** /dev/null 2015-07-28 11:36:43.193098438 +0200 --- gcc/testsuite/gfortran.dg/common_22.f90 2015-07-29 19:59:59.864974563 +0200 *************** *** 0 **** --- 1,24 ---- + ! { dg-do compile } + ! + ! PR fortran/59746 + ! Check that symbols present in common block are properly cleaned up + ! upon error. + ! + ! Contributed by Bud Davis + + CALL RCCFL (NVE,IR,NU3,VE (1,1,1,I)) + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + ! the PR only contained the two above. + ! success is no segfaults or infinite loops. + ! let's check some combinations + CALL ABC (INTG) + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + CALL DEF (NT1) + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + CALL GHI (NRESL) + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + END --------------090301000003080501040400 Content-Type: text/x-patch; name="pr59746_4_c.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="pr59746_4_c.diff" Content-length: 4519 Index: fortran/symbol.c =================================================================== *** fortran/symbol.c (révision 226157) --- fortran/symbol.c (copie de travail) *************** *** 3168,3216 **** FOR_EACH_VEC_ELT (latest_undo_chgset->syms, i, p) { ! if (p->gfc_new) { ! /* Symbol was new. */ ! if (p->attr.in_common && p->common_block && p->common_block->head) ! { ! /* If the symbol was added to any common block, it ! needs to be removed to stop the resolver looking ! for a (possibly) dead symbol. */ ! if (p->common_block->head == p && !p->common_next) { ! gfc_symtree st, *st0; ! st0 = find_common_symtree (p->ns->common_root, ! p->common_block); ! if (st0) ! { ! st.name = st0->name; ! gfc_delete_bbt (&p->ns->common_root, &st, compare_symtree); ! free (st0); ! } } ! if (p->common_block->head == p) ! p->common_block->head = p->common_next; ! else ! { ! gfc_symbol *cparent, *csym; ! ! cparent = p->common_block->head; ! csym = cparent->common_next; ! ! while (csym != p) ! { ! cparent = csym; ! csym = csym->common_next; ! } ! gcc_assert(cparent->common_next == p); ! cparent->common_next = csym->common_next; } - } /* The derived type is saved in the symtree with the first letter capitalized; the all lower-case version to the derived type contains its associated generic function. */ --- 3168,3216 ---- FOR_EACH_VEC_ELT (latest_undo_chgset->syms, i, p) { ! /* Symbol was new. Or was old and just put in common */ ! if ((p->gfc_new ! || (p->attr.in_common && !p->old_symbol->attr.in_common )) ! && p->attr.in_common && p->common_block && p->common_block->head) { ! /* If the symbol was added to any common block, it ! needs to be removed to stop the resolver looking ! for a (possibly) dead symbol. */ ! if (p->common_block->head == p && !p->common_next) ! { ! gfc_symtree st, *st0; ! st0 = find_common_symtree (p->ns->common_root, ! p->common_block); ! if (st0) { ! st.name = st0->name; ! gfc_delete_bbt (&p->ns->common_root, &st, compare_symtree); ! free (st0); } + } ! if (p->common_block->head == p) ! p->common_block->head = p->common_next; ! else ! { ! gfc_symbol *cparent, *csym; ! cparent = p->common_block->head; ! csym = cparent->common_next; ! while (csym != p) ! { ! cparent = csym; ! csym = csym->common_next; } + gcc_assert(cparent->common_next == p); + cparent->common_next = csym->common_next; + } + } + if (p->gfc_new) + { /* The derived type is saved in the symtree with the first letter capitalized; the all lower-case version to the derived type contains its associated generic function. */ Index: testsuite/gfortran.dg/common_22.f90 =================================================================== *** testsuite/gfortran.dg/common_22.f90 (révision 0) --- testsuite/gfortran.dg/common_22.f90 (copie de travail) *************** *** 0 **** --- 1,24 ---- + ! { dg-do compile } + ! + ! PR fortran/59746 + ! Check that symbols present in common block are properly cleaned up + ! upon error. + ! + ! Contributed by Bud Davis + + CALL RCCFL (NVE,IR,NU3,VE (1,1,1,I)) + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + ! the PR only contained the two above. + ! success is no segfaults or infinite loops. + ! let's check some combinations + CALL ABC (INTG) + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + CALL DEF (NT1) + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + CALL GHI (NRESL) + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL !{ dg-error "Unexpected COMMON" } + END --------------090301000003080501040400--