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 668578 Details for
Bug 890060
pthread mutex segfaults inside C++ class
[?]
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.
Source code to show bug
pthread.cpp (text/plain), 1.06 KB, created by
mdblack98
on 2012-12-24 19:41:59 UTC
(
hide
)
Description:
Source code to show bug
Filename:
MIME Type:
Creator:
mdblack98
Created:
2012-12-24 19:41:59 UTC
Size:
1.06 KB
patch
obsolete
>#include <iostream> >#include <pthread.h> > >using namespace std; > > >#ifndef BUG >pthread_mutex_t mutex; >#endif > >class MyThread { >private: > pthread_t threadid; >#ifdef BUG > pthread_mutex_t mutex; >#endif >public: > MyThread(); > ~MyThread(); > pthread_t get_threadid() { > return threadid; > }; > void *myfunc(void*); >}; > >MyThread::MyThread() >{ > mutex = PTHREAD_MUTEX_INITIALIZER; > cout << "Creating thread mutex=" << &mutex << endl; > pthread_create(&threadid,NULL,(void*(*)(void*))&MyThread::myfunc,NULL); >} > >MyThread::~MyThread() >{ >} > > >void *MyThread::myfunc(void*) >{ > int n=0; > cout << "In thread" << endl; > while (n < 10) { > pthread_mutex_lock(&mutex); > sleep(1); > pthread_mutex_unlock(&mutex); > cout << "Testing " << ++n << endl; > } > return NULL; >} > >int main(int argc, char *argv[]) >{ > MyThread thread; > pthread_t threadid = thread.get_threadid(); > cout << argv[0] << " running" << endl; > sleep(5); > pthread_join(threadid,NULL); > 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 890060
: 668578