On Tue, 18 Mar 2025 at 15:04, Peter Maydell <peter.mayd...@linaro.org> wrote: > More generally, AIUI glibc expects that it has control over what's > happening with threads, so it can set up its own data structures > for the new thread (e.g. for TLS variables). This email from the > glibc mailing list is admittedly now two decades old > https://public-inbox.org/libc-alpha/200408042007.i74k7zor025...@magilla.sf.frob.com/ > but it says: > > # Basically, if you want to call libc functions you should do it from a > # thread that was set up by libc or libpthread. i.e., if you make your own > # threads with clone, only call libc functions from the initial thread.
I spoke to some glibc devs on IRC and they confirmed that this remains true for modern glibc: because glibc needs to set up things like TLS on new threads, you can't mix your own direct calls to clone() with calls to glibc functions. -- PMM