|
Are you sure the problem is actually related to std::string ? It sounds to me as if the client of the COM object is calling an interface method through a bad or NULL this pointer. What is the value of the this pointer when it's corrupted?
Steve
|
|
|
|
|
I'm not a 100% that it is related to std::string of course but the evidence that I've seen so far (through the debugger) appears to point to that. So these are a set of sample values of the this pointer before and after corruption:
Before the std::string declaration: 0x01779408 (debugger tells me that it's pointing to a valid object, it has valid members etc)
In the constructor of the string: 0x0012f174
After the string has been constructed: 0x0012f18c (i.e. not null but not our original this pointer either)
I should have mentioned earlier (it has just entered my mind) that the project that I am working on makes use of STLPort and so the std::string is the STLPort std::string. Possibly could be a bug in STLPort...just not sure why it's occuring now for this particular project and not for the many, MANY other times when I've used std::string without even having to think about it...
|
|
|
|
|
Make sure you're not violating the One Definition Rule[^]. I suspect this as you said you're using STLPort. My guess is that you may not be using it contently across translations units (ie. using the default STL in some file or lib and using STLPort in another file or lib).
Steve
|
|
|
|
|
Possibly. At least I have a starting point with which to start looking into this now. Thanks!
|
|
|
|
|
jozsurf wrote: Obviously it could be something in the project settings which is setting this off
Yes, In my case this was true, but not sure about yours!
I will explain mine...
First bit of a background. I am porting a project in VC6 to VC8.
So I had two projects Project1 and Project2. So my first project is a lib project. Project2 statically links to Project1. So whenever I used std::map in my Project1 class Project2 crashed. "this" was getting corrupted, I just couldn't understand what was wrong.
So my sixth sense came into play and I checked the project settings, and there it was, Project1 didn't have "_SECURE_SCL=0 " defined and Project2 had this set, so obviously as we know that _SECURE_SCL does add some piece of code.
So immediately I made my project settings of all projects consistent and all crashes disappeared.
Don't know if this is the case with you. But I am sure there is something in your project settings that's causing this problem. Most probably _SECURE_SCL related stuff.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
This is a nasty problem that can be hard to diagnose. Technically it's a violation of the One Definition Rule[^].
Steve
|
|
|
|
|
Yeah it does sound like it has something to do with the project settings eh? I mentioned (in a separate response in this same thread) that STLPort is being used in this project; it could well be that the settings used for building the STLPort library is different (as in the case you described). Now I just need to track down the project settings for the version of STLPort we are using...worth a look anyhow.
cheers!
|
|
|
|
|
code:
CString myfunc()
{
return CString(_T("a string"));
}
CString myfunc2()
{
return CString(_T("a string2"));
}
int _tmain(void)
{
CString tempStr(_T("hello"));
tempStr.Empty();
tempStr= myfunc();
tempStr.Empty();
tempStr = myfunc2();
}
|
|
|
|
|
|
Thanks. Before I alway do in this manner, now I clear my mind!
|
|
|
|
|
you could have step into the MFC source code and clear you mind.
|
|
|
|
|
when ever you assign new value to CString object, it will refresh it internal data member with new values!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
ThatsAlok when ever you assign new value to CString object, it will refresh it internal data member with new values!
Does "assign new value" also count for a CString::Format () call?
So:
CString csNotEmpty = "hee hee";
csNotEmpty.Format ("another value");
Can I be sure that csNotEmpty ends up with the value "another value", or do I need to make the
(disabled) Empty () call in between?
Thanks in advance\0
(__..-=.: nul26 :.=-..__)
|
|
|
|
|
nul26 wrote: CString csNotEmpty = "hee hee";// csNotEmpty.Empty ();csNotEmpty.Format ("another value");
this will work!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hello everyone,
I never looked deep into the _p and dlldata file before, because they are automatically generated by MIDL compiler.
Today I opened them for study (I create them with ATL wizard), I can find and open them, but I do not understand what are the differences between _p file and dlldata file -- what are different function they are focused on?
For example, suppose I have an ATL coclass named TestATL1, then _p file I mean TestATL1_p.c and dlldata file I mean dlldata.c,
thanks in advance,
George
|
|
|
|
|
now i want to set the other color(backgroud and foreground color) for one item in the listctrl box?how can i do?
thanks
|
|
|
|
|
|
|
Hello everyone,
When making outgoing calls to other apartment in STA, the owner thread of
STA is not blocked and continue to do message pump, it is the RPC thread
(which is responsible for sending marshalled result to destination apartment)
is blocked? Is my understanding correct?
thanks in advance,
George
|
|
|
|
|
I just downloaded a Source from 'http://www.codeproject.com/KB/files/cfilemanip.aspx[^]'
Downloaded the zip to the desktop, with the Idea of expanding into an Appropriate Folder.
My Problem is, that the .ZIP file refuses to open, and Expand.
I get an Explorer window to Browse, but it has no menu items to expand it to a Folder.
Cannot find WinZip either to forcefully open this!
What the F***k is wrong
Bram van Kampen
|
|
|
|
|
Try this from MyComputer: Click on the file, right click, select "extract all...".
|
|
|
|
|
sometimes curse are not allowed in public programming forums!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
The function is like this :
int __cdecl _vsnprintf(char *Dest, size_t Count, const char *Format, va_list Args)
{
int v4; // edi@1
char *v6; // esi@1
char v7; // sf@2
FILE v8; // [sp+8h] [bp-20h]@1
v6 = Dest;
v8._cnt = Count;
v8._flag = 66;
v8._base = Dest;
v8._ptr = Dest;
v4 = sub_10078E3D(&v8, Format, Args);
if ( v6 )
{
v7 = v8._cnt-- < 1;
if ( v7 )
_flsbuf(0, &v8);
else
*v8._ptr = 0;
}
return v4;
}
I want to hook it like this i change the return address to mynes because i dont wanna change any bytes thnx for the helper
|
|
|
|
|
Hi ,
I hope this is the correct forum to post the message.
I am using RtlInitUnicodeString(UNICODE_STRING , WCHAR_T);
But i get access violation error when i am trying to execute the exe.
Could any one help me with the problem.
|
|
|
|
|
Could you please post the code snippet?
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|