Thomas Hoffmann
2001-Nov-23 21:43 UTC
[R] eval.c: possible issue with profiling for Windows
I see a possible problem with the "wait" parameter for the profiler thread: static void R_InitProfiling(char * filename, int append, double dinterval) { int wait; Here is the (automatic) variable. HANDLE Proc = GetCurrentProcess(); .......... wait = interval/1000; if(!(ProfileEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) || (_beginthread(ProfileThread, 0, &wait) == -1)) Here the address of wait is given to the thread R_Suicide("unable to create profiling thread"); R_Profiling = 1; Here you leave your function, invalidating "wait" by freeing its memory. } Depending on the compiler (and/or hardware!) used, this can lead to a race condition: You have invalidated "wait" by leaving R_InitProfiling, before your new thread had a chance to copy it to its local storage. One can either implement a semaphore handshake here (parent waits untils the thread has copied "wait" and then posted an event semaphore), or one can of course simply make "wait" static. (This concerns R 1.3.1, because I use a 33kb modem line: forget this mail if this has changed in newer release (or if it's a wrong conclusion, of course)). -- Thomas Hoffmann Telephone: 49-351-4598831 thoffman at zappa.sax.de Dresden, Germany ..sig under construction ... -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Apparently Analagous Threads
- (PR#996) Double inclusion of "int R_OutputCon" from
- Configuration: libpng needs zlib, but ...
- Dokumentation bug in src/include/Graphics.h (R-1.3.0) (PR#994)
- src/modules/Makefile.in: What is the (practical) difference betw. SUBDIRS and MODULES?
- check() warnings for survival-2.6