尝试在 Windows 7 上使用 tcl 线程会导致访问冲突

发布于 2024-08-16 22:01:34 字数 610 浏览 3 评论 0原文

我试图让这个简单的程序在 Windows 上运行,但它崩溃了:

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);
}

我正在使用由 cmake 生成的 makefile 并链接到我使用 Visual C++ 2008 Express 自己编译的 Tcl 8.5.7 版本。它是使用 msvcrt,static,threads 编译的,生成的库的名称是 tcl85tsx.lib。错误是:

Unhandled exception at 0x77448c39 in main.exe: 0xC0000005: Access violation writing location 0x00000014.

Tcl 库工作正常,我什至可以通过将 Thread 扩展加载到其中来运行线程脚本示例。我的假设是内存违规存在严重错误,但我不知道是什么。任何帮助表示赞赏。

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 is something horribly wrong with a memory violation, but I have no idea what. Any help appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱格式化 2024-08-23 22:01:34

当您调用 Tcl_FindExecutable() 时,会调用 TclInitSubsystems,该函数是公共的。如果您没有可用的可执行文件名称,只需在此处传递 NULL 即可。

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.

以可爱出名 2024-08-23 22:01:34

我最终编译了 Tcl 的可调试版本。问题是您需要调用 TclInitSubsystems 来初始化线程创建所需的所有锁。不幸的是,这不是公开访问的,并且需要使用 Tcl_CreateInterp 创建解释器。这是我正在开发的具有 Tcl 解释器的应用程序的测试程序,因此在生产中不会出现问题。我只需要为这个简单的测试程序创建一个解释器。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文