qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] trace/simple: fix hang in child after fork(2


From: Cornelia Huck
Subject: Re: [Qemu-devel] [PATCH v2] trace/simple: fix hang in child after fork(2)
Date: Mon, 16 Jul 2018 13:09:34 +0200

On Sun, 15 Jul 2018 14:42:23 +0200
Paolo Bonzini <address@hidden> wrote:

> On 13/07/2018 20:42, Stefan Hajnoczi wrote:
> > +#ifndef _WIN32
> > +static void stop_writeout_thread(void)
> > +{
> > +    g_mutex_lock(&trace_lock);
> > +    trace_writeout_running = false;
> > +    g_cond_signal(&trace_available_cond);
> > +    g_mutex_unlock(&trace_lock);
> > +
> > +    g_thread_join(trace_writeout_thread);
> > +    trace_writeout_thread = NULL;
> > +}  
> 
> After stop_writeout_thread returns, another could start a write to the
> shared data structure---and the write would never finish, because the
> thread disappears after fork(2) returns.  This would leave the mutex
> locked, causing a deadlock soon after the fork.  So you need to lock
> trace_lock again here, and unlock it in restart_writeout_thread.

So, I suppose there will be a v3, right?

> 
> Apart from this, it looks good!

Did a quick run and it fixed the problems for me.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]