On Tue, Mar 31, 2015 at 09:25:26PM +0300, Ilya Verbin wrote:
> On Mon, Mar 30, 2015 at 18:42:02 +0200, Jakub Jelinek wrote:
> > Shouldn't either this function, or gomp_offload_image_to_device lock
> > also devicep->lock mutex and unlock at the end?
> > Where exactly I guess depends on if the devicep->* hook calls should be
> > guarded with the mutex or not.  If yes, it should be this function and
> > gomp_init_device.
> > 
> > > +      if (devicep->type != target_type || !devicep->is_initialized)
> > > + continue;
> > > +
> > 
> > Similarly.
> 
> Oops, there is a deadlock.  E.g. if gomp_map_vars locks devicep->lock and then
> calls gomp_fatal, the destructors from .fini section are executed, so
> gomp_mutex_lock in GOMP_offload_unregister will wait for devicep->lock.

Thus perhaps before calling gomp_fatal you should release the device lock
(if held) and register_lock (ditto).

        Jakub

Reply via email to