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 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; } Grüße, Thomas