[vtkusers] vtkBMPReader crashes when linking VTK statically

Øystein Skotheim oystein+vtk at edge.no
Wed Nov 21 17:12:46 EST 2007


Hello. I have problems with vtkBMPReader when I link statically against
VTK. The following small test program generates a crash:

--cut--
#include <vtkBMPReader.h>
int main(int argc, char **argv)
{
     vtkBMPReader *bmpReader = vtkBMPReader::New();
     bmpReader->SetFileName("c:\\test.bmp");
     bmpReader->Update();
     bmpReader->Delete();
     return 0;
}
--cut--

When the Update() command is run, the program crashes with the following
message:

"A buffer overrun has occurred in TestBmpReader.exe which has corrupted
the program's internal state. Press Break to debug the program or
Continue to terminate the program. For more details please see Help
topic 'How to debug Buffer Overrun Issues'"

Is there something I can do to prevent this from happening? If I link
against VTK dynamically the problem seems to disappear.

This is my stack trace:

--cut--
  	DispHelleristning.exe!__crt_debugger_hook() 	Unknown
	DispHelleristning.exe!__report_gsfailure()  Line 315 + 0x7 bytes	
  	DispHelleristning.exe!vtkOStrStreamWrapper::str()  Line 83 + 0x18
bytes	C++

DispHelleristning.exe!vtkDemandDrivenPipeline::ExecuteDataObject(vtkInformation 

* request=0x08d3ce08, vtkInformationVector * * inInfo=0x00000000,
vtkInformationVector * outInfo=0x08d3ccf0)  Line 463 + 0xe bytes	C++

DispHelleristning.exe!vtkDemandDrivenPipeline::ProcessRequest(vtkInformation 

* request=0x08d3cda8, vtkInformationVector * * inInfoVec=0x00000000,
vtkInformationVector * outInfoVec=0x08d3ccf0)  Line 193 + 0x17 bytes	C++

DispHelleristning.exe!vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation 

* request=0x08d3ce08, vtkInformationVector * * inInfoVec=0x00000000,
vtkInformationVector * outInfoVec=0x08d3ccf0)  Line 161 + 0x12 bytes	C++
  	DispHelleristning.exe!vtkDemandDrivenPipeline::UpdateDataObject()
Line 378 + 0x1d bytes	C++
  	DispHelleristning.exe!vtkDemandDrivenPipeline::UpdateInformation()
Line 391 + 0xc bytes	C++
  	DispHelleristning.exe!vtkStreamingDemandDrivenPipeline::Update(int
port=0)  Line 173 + 0xa bytes	C++
  	DispHelleristning.exe!vtkExecutive::Update()  Line 316 + 0x2 bytes	C++
  	DispHelleristning.exe!WinMain(HINSTANCE__ * hInstance=0x00400000,
HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00152349, int
nCmdShow=5)  Line 91 + 0x18 bytes	C++
  	DispHelleristning.exe!__tmainCRTStartup()  Line 578 + 0x1d bytes	
--cut--

These are the lines that eventually crash(?) in vtkostrstreamwrapper.cxx:

#if defined(VTK_USE_ANSI_STDLIB) && !defined(VTK_NO_ANSI_STRING_STREAM)
char* vtkOStrStreamWrapper::str()
{
   if(!this->Result)
     {
     std::string s = static_cast<ostringstream*>(&this->ostr)->str();
     this->Result = new char[s.length()+1];
     strcpy(this->Result, s.c_str());
     this->freeze();
     }
   return this->Result;
}

Any help would be appreciated. I want to make a small viewer program
which does not require all the VTK DLL's.


Best regards,
-- 

Øystein Skotheim
Scientist, Optical Measurement Systems and Data Analysis
SINTEF ICT [http://www.sintef.com/omd]





More information about the vtkusers mailing list