VC++ 当给出 %d 时,6.0 应用程序在 CString::Format 内崩溃
使用 %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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在分配内存时崩溃,则可能是由于堆损坏造成的。 在启用堆测试的情况下,在 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.
这可能不是这样,但我最近遇到了一个已知问题,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.