[Bug 3439] New: uClibc 0.9.28 pthread, malloc, fork
bugzilla at busybox.net
bugzilla at busybox.net
Wed Mar 9 07:15:41 UTC 2011
https://bugs.busybox.net/show_bug.cgi?id=3439
Summary: uClibc 0.9.28 pthread, malloc, fork
Product: uClibc
Version: <= 0.9.29.x
Platform: PC
OS/Version: Windows
Status: NEW
Severity: minor
Priority: P5
Component: Threads
AssignedTo: unassigned at uclibc.org
ReportedBy: s-e-r-g-e at yandex.ru
CC: uclibc-cvs at uclibc.org
Estimated Hours: 0.0
- pthread allocates memory in a loop
- at the same time fork is run in a loop
- when this sample is compiled against uClibc 0.9.28 and run, it hangs (fork()
does not return child)
- by adding usleep(1) before p = malloc(1) helps.
Any hints ?
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<pthread.h>
void *run(void *foo)
{
int i, j, k;
void *p;
for (i = 0; i < 1000; i++)
for (j = 0; j < 1000; j++)
for (k = 0; k < 1000; k++)
{
p = malloc(1);
free(p);
}
pthread_exit(NULL);
}
void main(void)
{
pthread_t thread;
int i, pid, status;
pthread_create(&thread, NULL, run, NULL);
for (i = 0; i < 1000; i++)
{
pid = fork();
if (pid < 0)
{
printf("fork error\n");
break;
}
if (pid > 0)
{
printf("fork parent: %d\n", pid);
wait(&status);
}
if (pid == 0)
{
printf("fork child: %d\n", getpid());
exit(0);
}
}
exit(1);
}
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the uClibc-cvs
mailing list