[vtk-developers] vtkImageConvolve crashes when malloc fails

Berk Geveci berk.geveci at kitware.com
Wed Jun 4 17:31:28 EDT 2008


>> I agree. VTK's handling of memory allocation failures is far from
>> optimal. How would you address it?
>
> When an algorithm is executed, is there a return value indicating it did not
> succeeded, or should we have to inspect
> the returning value? vtkAlgorithm update method returns void.

RequestData() has a return value that reports success/failure.
However, that would require adding an if() check to every single
method that causes allocation (as a side effect) and changing every
single client that calls those functions. For example,
InsertNextValue() of vtkDataArray may cause reallocation. Currently it
returns the id of the next value. That would have to change to return
something on failure and everything that calls accordingly. Such a
change will never happen. On the other hand, a simple change maybe
throwing an exception when malloc/realloc inside vtkDataArray fails.
It would be up to the application to catch it though.

-berk



More information about the vtk-developers mailing list