When does pthread_create() return EINVAL?

Manuel Lauss manuel.lauss@gmail.com
Sun May 19 15:11:00 GMT 2019


Servus Florian,

On Sun, May 19, 2019 at 3:35 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * Manuel Lauss:
>
> > When does pthread_create() return EINVAL?
> > I use qemu-user for mipsel, and after updating a python package in the mipsel
> > userland, pthread_create() in qemu-user started returning EINVAL.  I
> > looked through the source of pthread_create, but could not find an
> > explicit EINVAL anywhere.
>
> Do you know which system call fails?  It's probably something coming
> from the Linux emulation, and not one of the glibc's stack-related
> checks (which can produce EINVAL as well).

The failure comes from qemu's rcu (util/rcu.c):

static void __attribute__((__constructor__)) rcu_init(void)
{
[...]
    pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_child);
[...]
}

rcu_init_child()  calls   rcu_init_complete() which calls qemu_thread_create()
where then pthread_create() fails:

    qemu_thread_create(&thread, "call_rcu", call_rcu_thread,
                       NULL, QEMU_THREAD_DETACHED);
[..]
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    pthread_create([..], &attr, call_rcu_thread, NULL);

Here pthread_create() returns EINVAL.

Do you have any idea what might cause this?   I changed nothing but the
python script (Gentoo's portage)

Thanks!
     Manuel



More information about the Libc-help mailing list