[vtkusers] _CrtIsValidHeapPointer failed when reading a VTK file with vtkPolyDataReader under win32 (linux: no pb)

Benoit Scherrer benoitscherrer at gmail.com
Tue Jun 29 00:50:40 EDT 2010


I have a project using VTK (and QT). The whole project is organized with
modules, one of them being a dynamic
library (Core.dll, to provide some functions to plugins) and
other static. VTK is compiled in static mode.

For linux gcc, it requires to compile with the -fpic flag and everything is
fine, VTK seems to be correctly
called in all the modules.

Under Win32 with Visual Studio it is another story: _CrtIsValidHeapPointer
returns FALSE
and crashes the application when i try to read a VTK file with the following
simple code:

 vtkSmartPointer<vtkPolyDataReader> reader =

When looking at the call stack you can see that calls:

> msvcr90d.dll!_CrtIsValidHeapPointer(const void * pUserData)  Line 2103 C++
  msvcr90d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse)  Line 1317
+ 0x9 bytes C++
  msvcr90d.dll!_free_dbg(void * pUserData, int nBlockUse)  Line 1258 + 0xd
bytes C++
  msvcr90d.dll!free(void * pUserData)  Line 49 + 0xb bytes C++
  mriED.exe!vtkDataReader::ReadArray(const char * dataType, int numTuples,
int numComp)  Line 1915 + 0xc bytes C++
  mriED.exe!vtkDataReader::ReadPoints(vtkPointSet * ps, int numPts)  Line
1932 + 0x15 bytes C++
  mriED.exe!vtkPolyDataReader::RequestData(vtkInformation * __formal,
vtkInformation * __formal, vtkInformationVector * outputVector)  Line 165 +
0x13 bytes C++
  mriED.exe!vtkDataReader::ProcessRequest(vtkInformation * request,
vtkInformationVector * * inputVector, vtkInformationVector * outputVector)
 Line 3062 + 0x1e bytes C++
  mriED.exe!vtkExecutive::CallAlgorithm(vtkInformation * request, int
direction, vtkInformationVector * * inInfo, vtkInformationVector * outInfo)
 Line 747 + 0x21 bytes C++
  mriED.exe!vtkDemandDrivenPipeline::ExecuteData(vtkInformation * request,
vtkInformationVector * * inInfo, vtkInformationVector * outInfo)  Line 507 +
0x1d bytes C++
  mriED.exe!vtkDemandDrivenPipeline::ProcessRequest(vtkInformation *
request, vtkInformationVector * * inInfoVec, vtkInformationVector *
outInfoVec)  Line 279 + 0x1e bytes C++
* request, vtkInformationVector * * inInfoVec, vtkInformationVector *
outInfoVec)  Line 202 + 0x14 bytes C++
  mriED.exe!vtkDemandDrivenPipeline::UpdateData(int outputPort)  Line 449 +
0x28 bytes C++
  mriED.exe!vtkStreamingDemandDrivenPipeline::Update(int port)  Line 246 +
0x1c bytes C++
  mriED.exe!vtkExecutive::Update()  Line 315 + 0x11 bytes C++
  mriED.exe!vtkDemandDrivenPipeline::Update()  Line 313 C++
  mriED.exe!vtkStreamingDemandDrivenPipeline::Update()  Line 227 C++
  mriED.exe!vtkAlgorithm::Update()  Line 1167 + 0x1a bytes C++
  mriED.exe!VTKMeshReader::ReadVTK(const QString & filename)  Line 227 +
0x1d bytes C++

So it crashes in vtkDataReader::ReadArray , at the following line:

 vtkAbstractArray *vtkDataReader::ReadArray(const char *dataType, int
numTuples, int numComp)

  free(type);            << ERROR is there. 'type' is not in the current
  return array;

When VTK is compiled in SHARED (dll) everything works well. So the problem
seems to be
mixing dynamic and static libraries with a compilation of VTK as a static

Does mixing dynamic and static libraries is a really bad idea or is it a bug
from VTK?
(i liked the idea to compile VTK in static mode, to avoid to provide all the
dlls with
the exe)

I m using a pretty recent version of VTK from the Git repository (from June,

Thanks a lot for any idea!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100629/f1af70e7/attachment.htm>

More information about the vtkusers mailing list