Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C++ Libraries / June 2005

Tip: Looking for answers? Try searching our database.

Crash in _vsnprintf? va_args issue help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WXS - 23 Jun 2005 03:03 GMT
I'm porting an application from VC++ 6.0 to VC++ 2003 and I'm seeing crashes
sometimes when _vsnprintf is called sometimes with format strings that have
a"%s" in them.  When I debug the code within _vsnprintf_ it calls output and
internally after finding the %s it tries to get the next int parameter from
va_args through a macro (I presume the int is the address of the string it is
going to replace the %s with).  What it returns though is 0xcdcdcdcd bad
pointer and causes the code to fail later when it tries to access the
pointer.)

Compiling using multithreaded DLL libraries.
Anyone have any ideas?

The areas I have already looked at:
Checked calling conventions setup on all builds
Rebuild all/clean several times
Checked execution libraries to verify the correct ones are in place.
Cleared up any suspicious warnings in seemingly related libraries.
Debugged in assembly to see what is going on.  It looks like we are calling
TRACE2 or our internal log method that uses _vsnprintf and it copies the
format string into a stack variable and I see it seems to leave a space on
the stack that is cdcdcdcd that I think may account for the return value but
I'm not sure why yet.
Jochen Kalmbach [MVP] - 23 Jun 2005 19:24 GMT
Hi WXS!
> I'm porting an application from VC++ 6.0 to VC++ 2003 and I'm seeing crashes
> sometimes when _vsnprintf is called sometimes with format strings that have
[quoted text clipped - 4 lines]
> pointer and causes the code to fail later when it tries to access the
> pointer.)

Could you please provide a small repro-code?

One problem might be, that you pass an "CString" parameter without
casting to LPCSTR. Then only the address of the class is passed, which
is wrong!
Example:
CString str;
str = "Hello world!";
printf("%s", str);  // WRONG!
printf("%s", (LPCSTR) str);  // correct...

Signature

Greetings
  Jochen

   My blog about Win32 and .NET
   http://blog.kalmbachnet.de/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.