public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* When does pthread_create() return EINVAL?
@ 2019-05-19 10:34 Manuel Lauss
  2019-05-19 13:35 ` Florian Weimer
  0 siblings, 1 reply; 5+ messages in thread
From: Manuel Lauss @ 2019-05-19 10:34 UTC (permalink / raw)
  To: libc-help

Hello,

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.

(glibc.git x86_64)

Thanks!
    Manuel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: When does pthread_create() return EINVAL?
  2019-05-19 10:34 When does pthread_create() return EINVAL? Manuel Lauss
@ 2019-05-19 13:35 ` Florian Weimer
  2019-05-19 15:11   ` Manuel Lauss
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2019-05-19 13:35 UTC (permalink / raw)
  To: Manuel Lauss; +Cc: libc-help

* 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).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: When does pthread_create() return EINVAL?
  2019-05-19 13:35 ` Florian Weimer
@ 2019-05-19 15:11   ` Manuel Lauss
  2019-05-19 15:29     ` Manuel Lauss
  0 siblings, 1 reply; 5+ messages in thread
From: Manuel Lauss @ 2019-05-19 15:11 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-help

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: When does pthread_create() return EINVAL?
  2019-05-19 15:11   ` Manuel Lauss
@ 2019-05-19 15:29     ` Manuel Lauss
  2019-05-19 15:32       ` Manuel Lauss
  0 siblings, 1 reply; 5+ messages in thread
From: Manuel Lauss @ 2019-05-19 15:29 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-help

Ok, nevermind:  Newer versions of Gentoo's portage use PID namespaces
by default.  Disabling this feature
gets rid of the pthread_create() failures.

Sorry for the noise!
    Manuel

On Sun, May 19, 2019 at 5:10 PM Manuel Lauss <manuel.lauss@gmail.com> wrote:
>
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: When does pthread_create() return EINVAL?
  2019-05-19 15:29     ` Manuel Lauss
@ 2019-05-19 15:32       ` Manuel Lauss
  0 siblings, 0 replies; 5+ messages in thread
From: Manuel Lauss @ 2019-05-19 15:32 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-help

To illustrate:

# unshare -p
call_rcu 0x6003a570 (nil)  0x7ffda2896610
qemu: qemu_thread_create pthread_create: Invalid argument

Manuel

On Sun, May 19, 2019 at 5:29 PM Manuel Lauss <manuel.lauss@gmail.com> wrote:
>
> Ok, nevermind:  Newer versions of Gentoo's portage use PID namespaces
> by default.  Disabling this feature
> gets rid of the pthread_create() failures.
>
> Sorry for the noise!
>     Manuel
>
> On Sun, May 19, 2019 at 5:10 PM Manuel Lauss <manuel.lauss@gmail.com> wrote:
> >
> > 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-05-19 15:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-19 10:34 When does pthread_create() return EINVAL? Manuel Lauss
2019-05-19 13:35 ` Florian Weimer
2019-05-19 15:11   ` Manuel Lauss
2019-05-19 15:29     ` Manuel Lauss
2019-05-19 15:32       ` Manuel Lauss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).