English 中文(简体)
Crash within CString
原标题:

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:CSACSourceCodeWP Communications ServerHW 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

最佳回答

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.

问题回答

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





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签