[Bug 1757517] Re: An unused thread-local memory allocation can cause library calls to segfault.
Moosfet
1757517 at bugs.launchpad.net
Wed Mar 21 19:03:14 UTC 2018
To see the problem in Jack, this example from the Jack project can do
it:
https://github.com/jackaudio/example-clients/blob/master/simple_client.c
Just add the "static __thread anything[8 * 1048576]" to it and
previously-working code begins doing this instead:
Cannot create thread res = 22
JackMessageBuffer::Create cannot start thread
Cannot create message buffer
Cannot create thread res = 22
Cannot start Jack client listener
Cannot start channel
JackShmReadWritePtr1::~JackShmReadWritePtr1 - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
jack_client_open() failed, status = 0x21
At least on my system, to get that output, the size of the allocation
must be at least 514025 bytes. Using one byte less, it successfully
connects, but then segfaults later in a call to jack_activate();
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to glibc in Ubuntu.
https://bugs.launchpad.net/bugs/1757517
Title:
An unused thread-local memory allocation can cause library calls to
segfault.
Status in glibc package in Ubuntu:
New
Bug description:
I've discovered that adding "static __thread anything[8 * 1048576]" to
otherwise working programs will cause them to segfault. I've attached
a short example that demonstrates the problem.
Compile the attached program like this: gcc -o test test.c -lpthread
-lasound
When running it, it will display this:
Spawning thread...
Joining thread...
I'm a thread!
Segmentation fault
Unfortunately I haven't been able to figure out how to reproduce it
without using libasound, except that I can use libjack to trigger it
instead, but since that makes two independent libraries that have this
problem, I assume it is caused by something common between them, like
pthreads, GCC, or the Linux kernel.
FWIW, with the Jack version of the bug, I've seen it do two things.
With a larger allocation it displays messages about being unable to
create threads before failing to connect to its server. With a
smaller allocation, it connects to its server, but then segfaults
later in a different call to libjack.
In all cases, merely removing the "static __thread anything[8 *
1048576]" from the program causes the libraries to work correctly.
Since the variable is never accessed by anything, adding it to the
programs should have no effect.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1757517/+subscriptions
More information about the foundations-bugs
mailing list