From patchwork Thu Feb 20 11:09:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 322100 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5D3CD2C0098 for ; Thu, 20 Feb 2014 22:09:50 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=iHc+5vC0ZBBsBHJK zGG5DtqK97YxuKf4lO5ScRTfOnRiJBjn9Te+TaGcundzmK4f9YsrKzlROHxbpexx 1++F5inK8aT3/zwHMBhGvKopq+kGB+GCob9AiW3m2kcT5XEO2TrpDB4Br3Yv1T22 YtaLmXuzJd6LVTaAExihWJrwzE4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=W2du0a2y7sFvGSv3iSJba5 aKeFE=; b=Xnni080HjmiP5OmRm+2qlXIX0nM8cN4TsHmTKh7pcq4BBLxLMwx7Iz Sxjt4tbnjZs+3nDgdhsD/lo0Eyu/gx7nu3SW/yG3DpmUwWWE6Yg8Z32UGEcnDF4Z lYsPT0maxZtBqU6knxoButI/NqznYg9oOyaNrgDgmyfxdrxnE0uio= Received: (qmail 20420 invoked by alias); 20 Feb 2014 11:09:43 -0000 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 Received: (qmail 20405 invoked by uid 89); 20 Feb 2014 11:09:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Feb 2014 11:09:41 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1WGRVY-0006l3-4R from Thomas_Schwinge@mentor.com ; Thu, 20 Feb 2014 03:09:36 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 20 Feb 2014 03:09:35 -0800 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Thu, 20 Feb 2014 11:09:33 +0000 From: Thomas Schwinge To: CC: , , Jakub Jelinek , , Subject: Re: [gomp4] libgomp: plugin for non-shared memory host execution In-Reply-To: <87r46zt76g.fsf@schwinge.name> References: <87zjpehpz4.fsf@schwinge.name> <20131108154000.GP27813@tucnak.zalov.cz> <87lhzqs3tv.fsf@kepler.schwinge.homeip.net> <87r46zt76g.fsf@schwinge.name> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Thu, 20 Feb 2014 12:09:31 +0100 Message-ID: <8738jerqfo.fsf@schwinge.name> MIME-Version: 1.0 Hi! On Wed, 19 Feb 2014 17:10:15 +0100, I wrote: > $ gcc -m64 -Wall -Wextra -shared -o libgomp-plugin-host.so.1 [...]/libgomp/plugin-host.c -fPIC -O -DDEBUG > > ..., and then set LIBGOMP_PLUGIN_PATH=$PWD in the environment. If putting plugins for several architectures into the same directory (as required for 32-bit as well as 64-bit x86 GNU/Linux testing, »RUNTESTFLAGS='--target_board=unix\{,-m32\}'«), libgomp will crash when loading the incompatible library; a bug that I introduced: > commit 8495aab54fb244ef2643e43eb3e91a092ff0b14e > Author: Thomas Schwinge , James Norris > Date: Wed Feb 19 16:53:14 2014 +0100 > > libgomp: plugin for non-shared memory host execution. > --- libgomp/target.c > +++ libgomp/target.c > @@ -608,28 +618,43 @@ static bool > gomp_load_plugin_for_device (struct gomp_device_descr *device, > const char *plugin_name) > { > - if (!device || !plugin_name) > - return false; > - > - device->plugin_handle = dlopen (plugin_name, RTLD_LAZY); > - if (!device->plugin_handle) > - return false; > + char *err = NULL; > > /* Clear any existing error. */ > dlerror (); > > + device->plugin_handle = dlopen (plugin_name, RTLD_LAZY); > + if (!device->plugin_handle) > + { > + err = dlerror (); > + goto out; > + out: > + if (err != NULL) > { > + gomp_error ("while loading %s: %s", plugin_name, err); > dlclose (device->plugin_handle); > - return false; > } > - > - return true; > + return err == NULL; Fixed in r207940 as follows: commit 4b51d1f28358bf60e96c4d6f3c78f1d7d52c4061 Author: tschwinge Date: Thu Feb 20 11:03:13 2014 +0000 libgomp: Avoid potential crash in plugin error handling. * target.c (gomp_load_plugin_for_device): Don't call dlcose if dlopen failed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@207940 138bc75d-0d04-0410-961f-82ee72b054a4 Grüße, Thomas diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp index c764b17..3dffde4 100644 --- libgomp/ChangeLog.gomp +++ libgomp/ChangeLog.gomp @@ -1,4 +1,9 @@ 2014-02-20 Thomas Schwinge + + * target.c (gomp_load_plugin_for_device): Don't call dlcose if + dlopen failed. + +2014-02-20 Thomas Schwinge James Norris * plugin-host.c: New file. diff --git libgomp/target.c libgomp/target.c index 83fcbd2..a6a5505 100644 --- libgomp/target.c +++ libgomp/target.c @@ -647,7 +647,8 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device, if (err != NULL) { gomp_error ("while loading %s: %s", plugin_name, err); - dlclose (device->plugin_handle); + if (device->plugin_handle) + dlclose (device->plugin_handle); } return err == NULL; }