[yast-commit] r60650 - in /branches/SuSE-Code-11-SP1-Branch/core/liby2util-r: src/y2log.cc testsuite/test_thread_log.cc

Author: mvidner Date: Tue Feb 2 10:03:09 2010 New Revision: 60650 URL: http://svn.opensuse.org/viewcvs/yast?rev=60650&view=rev Log: Added comments, cosmetic test case changes. Modified: branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/src/y2log.cc branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/test_thread_log.cc Modified: branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/src/y2log.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/core/l... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/src/y2log.cc (original) +++ branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/src/y2log.cc Tue Feb 2 10:03:09 2010 @@ -322,6 +322,7 @@ else tolog = y2_logfmt_prefix (level) + common; // store the message for worse times + // (lock the variable that is shared among threads, bnc#565918) static pthread_mutex_t blanik_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock (&blanik_mutex); blanik.push_back (tolog); Modified: branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/test_thread_log.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/core/l... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/test_thread_log.cc (original) +++ branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/test_thread_log.cc Tue Feb 2 10:03:09 2010 @@ -1,5 +1,10 @@ // adapted from // http://en.wikipedia.org/wiki/POSIX_Threads#Example + +// Test case for bnc#565918: +// The container variable for y2debug messages was not protected from +// concurrent thread access. +// Simply invoke y2debug from several threads many times to make it crash. #include <pthread.h> #include <stdio.h> #include <stdlib.h> @@ -24,21 +29,24 @@ int main (int argc, char *argv[]) { pthread_t threads[NUM_THREADS]; - + + // enable collecting y2debug messages setenv("Y2DEBUGONCRASH", "1", 1 /*overwrite*/); - ticks = argv[1]? atoi(argv[1]): 1000; + ticks = argc>1? atoi(argv[1]): 1000; int rc; intptr_t t; for(t=1; t<=NUM_THREADS; t++){ - printf("In main: creating thread %p\n", (void*)t); + printf("In main: creating thread %p\n", (void*)t); rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t); if (rc){ printf("ERROR; return code from pthread_create() is %d\n", rc); - exit(-1); + return 1; } } pthread_exit(NULL); + // if the bug exists, the program crashes before it can exit succesfully + return 0; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
mvidner@svn.opensuse.org