Trying to use tcl threads on windows 7 results in access violation
I'm trying to get this simple program to work on windows, but it crashes:
unsigned (__stdcall testfoo)(ClientData x) { return 0; } int main() { Tcl_ThreadId testid = 0; Tcl_CreateThread(&testid, testfoo, (ClientData) NULL, TCL_THREAD_STACK_DEFAULT, TCL_THREAD_NOFLAGS); }
I am using a makefile generated by cmake and linking against a version of Tcl 8.5.7 I compiled myself using Visual C++ 2008 express. It was compiled using msvcrt,static,threads and the name of the resulting library is tcl85tsx.lib. The error is:
Unhandled exception at 0x77448c39 in main.exe: 0xC0000005: Access violation writing location 0x00000014.
The Tcl library works fine, and I can even run a threading script example by loading the Thread extension into it. My assumption is that there 开发者_JAVA技巧is something horribly wrong with a memory violation, but I have no idea what. Any help appreciated.
TclInitSubsystems
is called when you call Tcl_FindExecutable()
, which is public. If you don't have the executable name to hand, just pass NULL there.
I ended up compiling a debuggable version of Tcl. The issue is that you need to call TclInitSubsystems to initialize all the locks required for thread creation. Unfortunately, this isn't publically accessible, and an intepreter needs to be created with Tcl_CreateInterp. This was a test program for an application I was developing that has a Tcl interpreter, so it will not be an issue in production. I just need to create an interpreter for this simple test program.
精彩评论