CString 内崩溃

发布于 2024-08-11 06:32:26 字数 998 浏览 5 评论 0原文

我观察到我的应用程序发生崩溃,调用堆栈如下所示,

mfc42u!CString::AllocBeforeWrite+5    
mfc42u!CString::operator=+22 

不知道为什么会发生这种情况。这种情况也不经常发生。 任何建议都会有所帮助。我有故障转储,但无法进一步进行。

我正在执行的操作是这样的,

iParseErr += m_RawMessage[wMsgLen-32] != NC_SP;

其中 m_RawMessage 是一个 512 长度的字符数组。 wMsgLen 是无符号短整型 NC_SP 定义为

#define NC_SP   0x20     // Space

编辑:

调用堆栈:

042afe3c 5f8090dd mfc42u!CString::AllocBeforeWrite+0x5 * WARNING: Unable to verify checksum for WP Communications Server.exe 
042afe50 0045f0c0 mfc42u!CString::operator=+0x22 
042aff10 5f814d6b WP_Communications_Server!CParserN1000::iCheckMessage(void)+0x665 [V:\CSAC\SourceCode\WP Communications Server\HW Parser N1000.cpp @ 1279] 
042aff80 77c3a3b0 mfc42u!_AfxThreadEntry+0xe6 
042affb4 7c80b729 msvcrt!_endthreadex+0xa9
042affec 00000000 kernel32!BaseThreadStart+0x37 

这是完整的调用堆栈,我已发布了原始消息中的代码片段,

谢谢

I am observing a crash within my application and the call stack shows below

mfc42u!CString::AllocBeforeWrite+5    
mfc42u!CString::operator=+22 

No idea why this occuring. This does not occur frequently also.
Any suggestions would help. I have the crash dump with me but not able to progress any further.

The operation i am performing is something like this

iParseErr += m_RawMessage[wMsgLen-32] != NC_SP;

where m_RawMessage is a 512 length char array.
wMsgLen is unsigned short
and NC_SP is defined as

#define NC_SP   0x20     // Space

EDIT:

Call Stack:

042afe3c 5f8090dd mfc42u!CString::AllocBeforeWrite+0x5 * WARNING: Unable to verify checksum for WP Communications Server.exe 
042afe50 0045f0c0 mfc42u!CString::operator=+0x22 
042aff10 5f814d6b WP_Communications_Server!CParserN1000::iCheckMessage(void)+0x665 [V:\CSAC\SourceCode\WP Communications Server\HW Parser N1000.cpp @ 1279] 
042aff80 77c3a3b0 mfc42u!_AfxThreadEntry+0xe6 
042affb4 7c80b729 msvcrt!_endthreadex+0xa9
042affec 00000000 kernel32!BaseThreadStart+0x37 

Well this is complete call stack and i have posted the code snippet as in my original message

Thanks

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

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

发布评论

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

评论(2

只为守护你 2024-08-18 06:32:26

我有一个可能会让你有点沮丧的建议:

CString::AllocBeforeWrite 确实暗示了我,系统试图分配一些内存。

有没有可能,其他一些内存操作(特别是释放或调整内存大小)之前已损坏?

C/C++ 内存管理的一个典型问题是,释放(或调整大小)内存时出现的错误(例如两次释放相同的内存垃圾)不会立即导致系统崩溃,但可能会导致稍后转储 — 特别是在新内存时内存要被分配。

你的情况在我看来很像那样。

坏处是:

很难找到真正发生错误的地方——堆首先被​​损坏的地方。

这也可能是您的问题偶尔出现一次的原因。这可能取决于事前一些复杂的情况。

I have a suggestion that might be a little frustrating for you:

CString::AllocBeforeWrite does implicate to me, that the system tries to allocate some memory.

Could it be, that some other memory operation (specially freeing or resizing of memory) is corrupted before?

A typical problem with C/C++ memory management is, that an error on freeing (or resizing) memory (for example two times freeing the same junk of memory) will not crash the system immediatly but can cause dumps much later -- specially when new memory is to be allocated.

Your situation looks to me quite like that.

The bad thing is:

It can be very difficult to find the place where the real error occurs -- where the heap is corrupted in the first place.

This also can be the reason, why your problem only occurs once in a while. It could depend on some complicated situation beforehand.

百合的盛世恋 2024-08-18 06:32:26

我相信您已经检查过明显的内容:wMsgLen >= 32

I'm sure you'll have checked the obvious: wMsgLen >= 32

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