Jump to content
  • Advertisement
Sign in to follow this  
steve coward

Help with boundschecker ifstream problem

This topic is 3679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am running my app (C++, 2005 Express Edition) under DevPartner Error Detection program (Boundschecker) and I am receiving the following error: Parameter 1, SIZE_T* _PtNumOfCharConverted = 0x00000000 in mbstowcs_s should not be null. Current Call Stack ------------------ _Fiopen fiopen.cpp basic_filebuf<char,struct std::char_traits<char> >::open fstream basic_ifstream<char,struct std::char_traits<char> >::basic_ifstream<char,struct std::char_traits<char> > fstream ReadRules tankbattle.cpp
std::string m_strAppRootPath; // as defined in pGameStatusInfo

std::string strRulesFile;
strRulesFile = m_pGameStatusInfo->m_strAppRootPath + "rules" + ".rsrc";
std::ifstream ifs(strRulesFile.c_str(), std::ios::in);  // <-- offending line

if (!ifs) {
else {
	while (!ifs.eof()) {
			ifs.getline(line, sizeof(line), '\n');

explicit __CLR_OR_THIS_CALL basic_ifstream(const char *_Filename,
		ios_base::openmode _Mode = ios_base::in,
		int _Prot = (int)ios_base::_Openprot)
		: basic_istream<_Elem, _Traits>(&_Filebuffer)
		{	// construct with named file and specified mode
		if (_Filebuffer.open(_Filename, _Mode | ios_base::in, _Prot) == 0)

_Myt *__CLR_OR_THIS_CALL open(const char *_Filename,
		ios_base::openmode _Mode,
		int _Prot = (int)ios_base::_Openprot)
		{	// open a C stream with specified mode
		_Filet *_File;
		if (_Myfile != 0 || (_File = _Fiopen(_Filename, _Mode, _Prot)) == 0)
			return (0);	// open failed

		_Init(_File, _Openfl);
		_Initcvt((_Cvt *)&_USE(_Mysb::getloc(), _Cvt));
		return (this);	// open succeeded

strRulesFile evaluates to a proper, full windows file name. Code compiles without warning and appears to run properly. If I examine strRulesFile in the debugger, I see that various member variables "deeper" into std::string structure are not well defined. For example, _Mycont and _Mynextiter are displayed as "CXX0030:Error:expression cannot be evaluated". Also the _Bx member _Buf seems to contain garbage. If I examine in the debugger _File as returned by _Fiopen, it is not equal to 0 and its three member variable pointers (_base, _ptr, _tmpfname) are listed as 0x00000000 <Bad Ptr>. Is this behavior expected or am I improperly using ifstream? Thanks for any comments,

Share this post

Link to post
Share on other sites
Judging by the lack of answers, it looks like there aren't many people familiar with "DevPartner Error Detection program (Boundschecker)". So I'll ask the obvious question:

What's the smallest compilable program in which the error can be reproduced? You've still got references to Direct3D in your code so I'm assuming you've copied the code out of a larger program and haven't yet tried to simmer it down.

Share this post

Link to post
Share on other sites
From Wikipedia:

"BoundsChecker is a memory checking tool used for C++ software development with Microsoft Visual C++. It is part of the DevPartner for Visual C++ BoundsChecker Suite. Comparable tools are Purify, Insure++ and Valgrind.

BoundsChecker can be run in two modes ActiveCheck which doesn't instrument the application and FinalCheck which does.

ActiveCheck performs a less intrusive analysis and monitors all calls by the application to the C Runtime Library, Windows API and calls to COM objects. By monitoring memory allocations and frees it can detect memory leaks and overruns. Monitoring API and COM calls enables ActiveCheck to check parameters, returns and exceptions and report exceptions when they occur. Thread deadlocks can also be detected by monitoring of the synchronization objects and calls giving actual and potential deadlock detection."

I am using the tool in ActiveCheck mode. That many people are not familiar with it is not surprising to me given its prohibitive cost. I am using
a trial version. Perhaps some people have used it in a business environment.

Even though the code I posted is from a much larger directx program, I
believe that the test case is essentially self contained - it is composed of the
declaration and assignment of one std::string which is a file path
to an existing, readable file and the attempt to open that file for reading.

This code has the same problem as pointed out by Boundschecker.

std::ifstream ifs;
ifs.open("test.txt", std::ios::in);

Share this post

Link to post
Share on other sites
I'm using BoundsChecker 7.2 in VS 2003 with C++.

It is quite valuable for a lot of things but it loves to go overboard with the STL. It also usually nags on any API call that fails (even if that is wanted behaviour).

Esp. with errors inside any STL code i tend to ignore the noted errors (once i checked that my passed parameters are correct).

See them as a warning that might need checking. You can also set specific errors in specific code files to be ignored.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!