qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PULL 02/46] qemu-thread: fix races on threads that exi


From: linzhecheng
Subject: Re: [Qemu-devel] [PULL 02/46] qemu-thread: fix races on threads that exit very quickly
Date: Thu, 21 Dec 2017 03:40:23 +0000


> -----邮件原件-----
> 发件人: Eric Blake [mailto:address@hidden
> 发送时间: 2017年12月21日 11:36
> 收件人: linzhecheng <address@hidden>; Paolo Bonzini
> <address@hidden>; address@hidden; address@hidden
> 抄送: wangxin (U) <address@hidden>
> 主题: Re: [Qemu-devel] [PULL 02/46] qemu-thread: fix races on threads that
> exit very quickly
> 
> On 12/20/2017 09:29 PM, linzhecheng wrote:
> 
> >> +} QemuThreadArgs;
> >> +
> >> +static void *qemu_thread_start(void *args) {
> >> +    QemuThreadArgs *qemu_thread_args = args;
> >> +    void *(*start_routine)(void *) = qemu_thread_args->start_routine;
> >> +    void *arg = qemu_thread_args->arg;
> >> +
> >> +    /* Attempt to set the threads name; note that this is for debug, so
> >> +     * we're not going to fail if we can't set it.
> >> +     */
> >> +    pthread_setname_np(pthread_self(), qemu_thread_args->name);
> >> +    g_free(qemu_thread_args->name);
> >> +    g_free(qemu_thread_args);
> > If qemu_thread_args is freed here, start_routine(arg) will lead to use
> > after free because arg equals to qemu_thread_args
> 
> No, we explicitly copied qemu_thread_args->arg into a local variable prior to
> freeing qemu_thread_args, so that we do not have to dereference the freed
> variable.
OK, that's true. 
> 
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org

reply via email to

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