From patchwork Tue Aug 23 15:19:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Lissy X-Patchwork-Id: 111130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1526CB722E for ; Wed, 24 Aug 2011 01:20:02 +1000 (EST) Received: (qmail 30897 invoked by alias); 23 Aug 2011 15:20:00 -0000 Received: (qmail 30887 invoked by uid 22791); 23 Aug 2011 15:20:00 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,TW_DL X-Spam-Check-By: sourceware.org Received: from hermes.univ-tours.fr (HELO hermes.univ-tours.fr) (193.52.209.50) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Aug 2011 15:19:44 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai4HAMLEU04KrAUU/2dsb2JhbABBhEuUQ5AFgUEBBSMEUhAYNQICVxmxTJF/hTiBEASYRItR Received: from unknown (HELO portable-alex.polytech.univ-tours.local) ([10.172.5.20]) by hermes2.univ-tours.fr with ESMTP; 23 Aug 2011 17:14:01 +0200 From: Alexandre Lissy To: gcc-patches@gcc.gnu.org Cc: gcc-melt@googlegroups.com, basile@starynkevitch.net, Alexandre Lissy Subject: [PATCH] Fix .so handling on failure Date: Tue, 23 Aug 2011 17:19:21 +0200 Message-Id: <1314112761-4914-2-git-send-email-alissy@mandriva.com> In-Reply-To: <1314112761-4914-1-git-send-email-alissy@mandriva.com> References: <1314112761-4914-1-git-send-email-alissy@mandriva.com> MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org When an invalid handle from dlopen() was generated, the else branch corresponding was not at the right place and was a child of 'if (!quiet_flag || flag_melt_debug)' condition. This leads to unloading of shared library just loaded by MELT runtime when debug is not enabled, hence the next call to mi->mmi_startrout() in meltgc_start_module_by_index would refer to an invalid address (shared library unloaded at the time of the call). --- gcc/ChangeLog.MELT | 3 +++ gcc/melt-runtime.c | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog.MELT b/gcc/ChangeLog.MELT index f4cc6a5..4282321 100644 --- a/gcc/ChangeLog.MELT +++ b/gcc/ChangeLog.MELT @@ -1,3 +1,6 @@ +2011-08-23 Alexandre Lissy + * melt-runtime.c (melt_load_module_index): Correct handling of invalid + dlopen handle. 2011-08-05 Basile Starynkevitch * melt-runtime.c (melt_run_make_for_plugin): Don't use fullbinfile. diff --git a/gcc/melt-runtime.c b/gcc/melt-runtime.c index 8eea8f1..ca580a4 100644 --- a/gcc/melt-runtime.c +++ b/gcc/melt-runtime.c @@ -8764,11 +8764,11 @@ melt_load_module_index (const char*srcbase, const char*flavor) MELTDESCR_REQUIRED(melt_gen_timestamp), MELTDESCR_REQUIRED(melt_build_timestamp)); } - else - { - debugeprintf ("melt_load_module_index invalid dlh %p sopath %s", dlh, sopath); - dlclose (dlh), dlh = NULL; - } + } + else + { + debugeprintf ("melt_load_module_index invalid dlh %p sopath %s", dlh, sopath); + dlclose (dlh), dlh = NULL; } end: if (srcpath)