Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#51948 - [glibc] Segfault when short-live threads are created with detached state

Attached to Project: Arch Linux
Opened by Jaroslaw Siebert (y0g1) - Thursday, 24 November 2016, 17:05 GMT
Last edited by Allan McRae (Allan) - Friday, 25 November 2016, 01:16 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Allan McRae (Allan)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: There is a bug in glibc, that cuse segfault when short-live threads are created with detached state. See:
https://sourceware.org/bugzilla/show_bug.cgi?id=20511
and
https://sourceware.org/bugzilla/show_bug.cgi?id=20116


Additional info:
* package version(s)
* config and/or log files etc.


Steps to reproduce:
Compile and run in loop test program:

#include <unistd.h>
#include <stdio.h>
#include <pthread.h>

#define QSIZE 64
pthread_mutex_t lock;
int active = QSIZE;
pthread_t ptr[QSIZE];
pthread_attr_t attr[QSIZE];

static void *threadapp(void *o)
{
pthread_mutex_lock(&lock);
active--;
pthread_mutex_unlock(&lock);
pthread_exit(NULL);
}

int main(int argc, char *argv[])
{
int j;
if(pthread_mutex_init(&lock, NULL) != 0) {
perror("mutex init");
return 1;
}
printf("Start");
fflush(stdout);
active = QSIZE;
for(j=0; j<QSIZE; ++j) {
int status;
do {
if(pthread_attr_init(&attr[j]) != 0) {
perror("attr init");
return 1;
}
pthread_attr_setdetachstate(&attr[j], PTHREAD_CREATE_DETACHED);
status = pthread_create(&ptr[j], &attr[j], &threadapp, NULL);
if(pthread_attr_destroy(&attr[j]) != 0) {
perror("attr destroy");
return 1;
}
}
while(status != 0);
}
for(;;) {
pthread_mutex_lock(&lock);
if(active == 0) {
pthread_mutex_unlock(&lock);
break;
}
pthread_mutex_unlock(&lock);
}
printf("...Done\n");
return 0;
}

Run it with:
while ./multitest; do sleep 0; done
In few minuts it will segfault.
This task depends upon

Closed by  Allan McRae (Allan)
Friday, 25 November 2016, 01:16 GMT
Reason for closing:  Upstream

Loading...