[R] eval.c: possible issue with profiling for Windows
thoffman at zappa.sax.de
Fri Nov 23 22:43:04 CET 2001
I see a possible problem with the "wait" parameter for the profiler
static void R_InitProfiling(char * filename, int append, double
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
condition: You have invalidated "wait" by leaving R_InitProfiling,
your new thread had a chance to copy it to its local storage.
One can either implement a semaphore handshake here (parent waits untils
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
this has changed in newer release (or if it's a wrong conclusion, of
Thomas Hoffmann Telephone:
thoffman at zappa.sax.de Dresden,
..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
More information about the R-help