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 1483451 Details for
Bug 1418919
malloc_printerr() deadlock, when calling malloc_printerr() again
[?]
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.
C process file
test2.c (text/plain), 2.76 KB, created by
wanjiankang
on 2018-09-15 07:09:29 UTC
(
hide
)
Description:
C process file
Filename:
MIME Type:
Creator:
wanjiankang
Created:
2018-09-15 07:09:29 UTC
Size:
2.76 KB
patch
obsolete
>#include <pthread.h> >#include <stdio.h> >#include <stdlib.h> >#include <signal.h> >#include <string.h> >#include <unistd.h> >#include <stdbool.h> > >volatile bool go = false; > >int extract_status_code(char *buffer, int size) >{ > char *buf_code; > char *buf_code2; > char *begin; > char *end = buffer + size; > int inc = 0; > > /* Allocate the room */ > buf_code = (char *)malloc(10); > > /* Status-Code extraction */ > while (buffer < end && *buffer++ != ' ') ; > begin = buffer; > while (buffer < end && *buffer++ != ' ') > inc++; > inc=40960; > strncat(buf_code, begin, inc); > inc = atoi(buf_code); > free(buf_code); > return inc; >} > >void* threadStart(void* arg) >{ > char buffer[4096] = "|sd fasdfasdf0HTTP/1.1200sdfsfsadfOKffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; > printf("status code %d\n", extract_status_code(buffer, 102400)); > while(!go) {} > pthread_exit(0); >} > >int main() >{ > unsigned int numThreads = 1000; > pthread_t threads[numThreads]; > void* threadReturns[numThreads]; > int retval = 0; > > printf("pthread start\n"); > // create lots of threads > int i = 0; > for(i=0; i < numThreads; i++) > { > pthread_attr_t attr; > retval = pthread_attr_init(&attr); > if(0 != retval) > { > fprintf(stderr, "pthread_attr_init failed: %d on thread %d\n", retval, i); > numThreads=i; > break; > } > > retval = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); > if(0 != retval) > { > fprintf(stderr, "pthread_attr_setdetachstate failed: %d on thread %d\n", retval, i); > numThreads=i; > break; > } > > retval = pthread_create(&threads[i], &attr, threadStart, 0); > if(0 != retval) > { > fprintf(stderr, "pthread_create failed: %d on thread %d\n", retval, i); > numThreads=i; > break; > } > } > > // Start the threads running > // Now they all try to exit at once. > sleep(10); > go = true; > > // join the threads and then exit. > int j = 0; > for(j=0; j < numThreads; j++) > { > pthread_join(threads[j], &threadReturns[j]); > } > > printf("pthread end\n"); > exit(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 1418919
:
1247372
|
1483450
| 1483451