CString 内崩溃
我观察到我的应用程序发生崩溃,调用堆栈如下所示,
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有一个可能会让你有点沮丧的建议:
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.
我相信您已经检查过明显的内容:wMsgLen >= 32
I'm sure you'll have checked the obvious: wMsgLen >= 32