Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 146184 Details for
Bug 223789
pthread_create() fails with segmentation fault.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
test program for reproducing the problem
thr_test_min.c (text/plain), 2.97 KB, created by
Jani Tolonen
on 2007-01-22 14:41:31 UTC
(
hide
)
Description:
test program for reproducing the problem
Filename:
MIME Type:
Creator:
Jani Tolonen
Created:
2007-01-22 14:41:31 UTC
Size:
2.97 KB
patch
obsolete
>/* Testing of thread creation to find memory allocation bug */ > >#include <pthread.h> >#include <stdio.h> >#include <stdlib.h> >#include <errno.h> > >#define TEST_COUNT 100000 >#define MAX_THREADS 100 >#define TEST_LOOP 10000 > >uint thread_count; >static pthread_cond_t COND_thread_count; >static pthread_mutex_t LOCK_thread_count; >uint global_sum; > >void *test_thread(void *arg) >{ > int i,sum=0; > for (i=0; i < TEST_LOOP; i++) /* Let the thread take a while */ > sum+=i; > global_sum+=sum; /* use the value */ > pthread_mutex_lock(&LOCK_thread_count); > thread_count--; > pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */ > pthread_mutex_unlock(&LOCK_thread_count); > pthread_exit(0); > return 0; >} > > >int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) >{ > pthread_t tid; > pthread_attr_t thr_attr; > int i,error; > > if ((error=pthread_cond_init(&COND_thread_count,NULL))) > { > fprintf(stderr,"Got error: %d from pthread_cond_init (errno: %d)", > error,errno); > exit(1); > } > if ((error=pthread_mutex_init(&LOCK_thread_count,NULL))) > { > fprintf(stderr,"Got error: %d from pthread_cond_init (errno: %d)", > error,errno); > exit(1); > } > if ((error=pthread_attr_init(&thr_attr))) > { > fprintf(stderr,"Got error: %d from pthread_attr_init (errno: %d)", > error,errno); > exit(1); > } > if ((error=pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED))) > { > fprintf(stderr, > "Got error: %d from pthread_attr_setdetachstate (errno: %d)", > error,errno); > exit(1); > } >#ifndef pthread_attr_setstacksize /* void return value */ > if ((error=pthread_attr_setstacksize(&thr_attr,65536L))) > { > fprintf(stderr,"Got error: %d from pthread_attr_setstacksize (errno: %d)", > error,errno); > exit(1); > } >#endif > printf("Init ok. Creating %d threads\n",TEST_COUNT); > for (i=1 ; i <= TEST_COUNT ; i++) > { > int *param= &i; > if ((i % 100) == 0) > { > printf("%8d",i); fflush(stdout); > } > if ((error=pthread_mutex_lock(&LOCK_thread_count))) > { > fprintf(stderr,"\nGot error: %d from pthread_mutex_lock (errno: %d)", > error,errno); > exit(1); > } > if ((error=pthread_create(&tid,&thr_attr,test_thread,(void*) param))) > { > fprintf(stderr,"\nGot error: %d from pthread_create (errno: %d) when creating thread: %i\n", > error,errno,i); > pthread_mutex_unlock(&LOCK_thread_count); > exit(1); > } > thread_count++; > pthread_mutex_unlock(&LOCK_thread_count); > > if ((error=pthread_mutex_lock(&LOCK_thread_count))) > fprintf(stderr,"\nGot error: %d from pthread_mutex_lock\n",error); > while (thread_count > MAX_THREADS) > { > if ((error=pthread_cond_wait(&COND_thread_count,&LOCK_thread_count))) > fprintf(stderr,"\nGot error: %d from pthread_cond_wait\n",error); > } > if ((error=pthread_mutex_unlock(&LOCK_thread_count))) > fprintf(stderr,"\nGot error: %d from pthread_mutex_unlock\n",error); > } > pthread_attr_destroy(&thr_attr); > printf("\nend\n"); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 223789
: 146184