Tcl version - current and all inspected - seems to
be a problem all the way back to introduction of
tclWinThrd.c so all v8.0 onwards
OS - Windows only problem, and only if Tcl interpreters
are not created (ie using tcl as a C library)
When Tcl is used as a library (e.g. for utf-8 or regexp
functions) on the Windows platform and TCL_THREADS
is defined during the build of Tcl, the functions will
produce a seg fault when the
macro is invoked because the masterLock variable has
not been initialized. This is not seen if Tcl_CreateInterp
has been invoked because TclpInitLock is called
However, the Tcl_RegExpCompile, for example is
supposed to be callable with the Tcl_Interp parameter
set to NULL (0).
In the unix implementation, the corresponding variable
is initialized at compile time through a static initializer
static pthread_mutex_t masterLock =
this cannot be done on windows because a call
to InitializeCriticalSection is required.
One possible fix is change the macro for MASTER_LOCK
to call the TclpMasterLock function in tclWinThrd.c
This seems reasonable and it only affects this one file.
In the meantime, it appears that a call to Tcl_GetTime
will initialize the masterLock mutex.