在 Windows 上检测多个链接的 C 运行时

发布于 2024-07-23 12:34:49 字数 126 浏览 4 评论 0原文

我在 Windows(64 位)上从事的项目之一遇到了一些问题。 该程序有时会崩溃,有时不会,我怀疑问题与多个链接的 C 运行时有关。 我如何在 Windows 上检测到这一点? 我尝试使用depends.exe,但它没有报告CRT

I have some problems with one of the projects I am working on on windows (64 bits). The program sometimes crash, sometimes does not, and I suspect the problem to be linked with multiple linked C runtime. How can I detect this on windows ? I tried with depends.exe, but it did not report the CRT

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

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

发布评论

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

评论(1

月亮邮递员 2024-07-30 12:34:49

您不太可能成功地静态链接多个 C 运行时库 - 您将遇到许多符号定义冲突,这至少会产生大量警告,只有鲁莽的工程师才会忽略它们。

使用 depends,我将确保使用动态分析选项来检查它们加载的动态 CRTL 的所有依赖项。 如果没有出现任何问题,我怀疑您的问题出在其他地方。

不过,无论如何,我怀疑您的问题出在其他地方,因为具有 C 级 API 的 DLL 通常不应该依赖于 CRTL(最常见的是内存分配器)中的共享状态,并且应该采用标准化协议跨API内存管理,例如调用者分配、被调用者使用或传入内存分配回调等。换句话说,由于正确使用内存管理协议,同一进程中的多个CRTL通常不会出现问题。

对于暂时性故障,我会怀疑多线程或堆损​​坏。

It's rather unlikely that you could successfully statically link against multiple C runtime libraries - you would run into many symbol definition conflicts which would at least produce voluminous warnings, and only a reckless engineer would ignore them.

With depends, I would make sure to use the dynamic profiling option, to check all dependencies for dynamic CRTLs they load. If doesn't turn up anything, I suspect your problem is elsewhere.

I would suspect your problem is elsewhere in any case, though, as DLLs with C-level APIs shouldn't, as a rule, rely on shared state in the CRTL - most commonly the memory allocator - and should have adopt a standardized protocol for cross-API memory management, such as caller-allocates, callee-uses, or passing in memory allocation callbacks, etc. In other words, multiple CRTLs in the same process is normally not a problem due to correct use of a memory management protocol.

For transient failures, I would suspect multithreading or heap corruption.

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