VC++ 当给出 %d 时,6.0 应用程序在 CString::Format 内崩溃

发布于 2024-07-26 18:39:59 字数 518 浏览 3 评论 0原文

使用 %d 格式说明符执行 CString::Format 操作时,VC++ 6.0 应用程序崩溃。 这种情况并不总是发生,而是在应用程序内存增长到 100MB 或更多时发生。 另外,当 CString 复制完成时,有时会观察到相同的崩溃。 调用堆栈看起来像这样

mfc42u!CFixedAlloc::Alloc+82

mfc42u!CString::AllocBuffer+3f 00000038 00000038 005b5b64

mfc42u!CString::AllocBeforeWrite+31 00000038 0a5bfdbc 005b5b64

mfc42u!CString::AssignCopy+13 00000038 057cb83f 0a5bfe90

mfc42u!CString::operator=+4b

这会引发访问冲突异常。

A VC++ 6.0 application is crashing when doing a CString::Format operation with %d format specifier. This does not occur always but occurs when the application memory grows upto 100MB or more.
ALso sometimes same crash observed when a CString copy is done.
The call stack would look like this

mfc42u!CFixedAlloc::Alloc+82

mfc42u!CString::AllocBuffer+3f
00000038
00000038
005b5b64

mfc42u!CString::AllocBeforeWrite+31
00000038
0a5bfdbc
005b5b64

mfc42u!CString::AssignCopy+13
00000038
057cb83f
0a5bfe90

mfc42u!CString::operator=+4b

and this throws an access violation exception.

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

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

发布评论

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

评论(2

衣神在巴黎 2024-08-02 18:40:00

如果您在分配内存时崩溃,则可能是由于堆损坏造成的。 在启用堆测试的情况下,在 AppVerifier 下运行应用程序。 这使您能够看到代码中的各种问题,例如双重释放、堆溢出/欠载等。

If you're crashing while allocating memory, then it may be due to heap corruption. Run your application under AppVerifier with the Heaps test enabled. This enable you to see various issues in your code like double frees, heap ovveruns/underruns and so on.

那些过往 2024-08-02 18:40:00

这可能不是这样,但我最近遇到了一个已知问题,realloc 损坏了小VS6下的块堆。 如果您在代码中的其他地方使用了 realloc(或使用类似使用 realloc 的向量之类的东西),则可能会导致您所看到的情况。

该问题的解决方法是破解 realloc.c,编写自己的 realloc 函数,或者在代码中执行“_set_sbh_threshold(0)”以禁用该过时的小块堆。

This probably isn't it, but I recently came across a known issue with realloc corrupting the small block heap under VS6. If you have a realloc (or use of something like vector that uses realloc) elsewhere in your code, it could cause what you are seeing.

The fix for the issue is to either hack realloc.c, write your own realloc function, or do a "_set_sbh_threshold(0)" in your code to disable that obsolete small block heap.

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