Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 132071 Details for
Bug 194076
Gentoo specific segfault with sys-libs/glibc (NPTL) and gcc-4.1.2
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
tiny test case which demonstrates the problem
nptl_test.c (text/plain), 1.94 KB, created by
Christian Schoenebeck
on 2007-09-28 11:51:05 UTC
(
hide
)
Description:
tiny test case which demonstrates the problem
Filename:
MIME Type:
Creator:
Christian Schoenebeck
Created:
2007-09-28 11:51:05 UTC
Size:
1.94 KB
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> >#include <pthread.h> > >pthread_attr_t __thread_attr; >pthread_t __thread_id; > >pthread_mutex_t __posix_mutex; >pthread_mutexattr_t __posix_mutexattr; > >/// entry point for the spawned thread >void* __pthread_launcher(void* p) { > // let the thread be killable under any circumstances > // (without this function call, this test always succeeds !) > pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); > > printf("2nd thread is running\n"); > fflush(stdout); > > // this will block this 2nd thread, since we already > // locked this mutex by the main thread > pthread_mutex_lock(&__posix_mutex); > > // here we would access shared resources, etc. > > // just pro forma, the remainder of this function is actually not of > // interest, since this thread is always terminated at its mutex lock call > pthread_mutex_unlock(&__posix_mutex); > return NULL; >} > >int main() { > // initialize mutex and thread attribute > pthread_mutexattr_init(&__posix_mutexattr); > pthread_mutex_init(&__posix_mutex, &__posix_mutexattr); > pthread_attr_init(&__thread_attr); > > // already lock the mutex by the main thread ... > pthread_mutex_lock(&__posix_mutex); > > int res; > > // create and run a 2nd thread > res = pthread_create(&__thread_id, &__thread_attr, __pthread_launcher, NULL); > if (res) { > printf("thread creation failed\n"); > fflush(stdout); > exit(-1); > } > > // give the other thread a chance to spawn > usleep(400000); > > // kill the other thread > pthread_cancel(__thread_id); > pthread_detach(__thread_id); > > // give the other thread a chance to finish its execution > usleep(400000); > > // cleanup > // (just pro forma, doesnt actually matter for this test case) > pthread_attr_destroy(&__thread_attr); > pthread_mutex_destroy(&__posix_mutex); > pthread_mutexattr_destroy(&__posix_mutexattr); > > printf("TEST PASSED! :-)\n"); > > return res; >}
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 194076
: 132071 |
165813