Page MenuHomePhabricator

Saving of more than 2^29 double values leads to crash.
Closed, WontfixPublic

Description

Execution of the following code leads to a crash on my machine (Windows 7, intel i7):

unsigned int x = pow(2, 29);
unsigned long size = x;

double* data = new double[size];
for (unsigned long i = 0; i < size; i++)
  data[i] = 0;

mitk::Image::Pointer image = mitk::Image::New();
mitk::PixelType TPixel = mitk::MakeScalarPixelType<double>();
unsigned int* dimensionsOfImage = new unsigned int[1];
dimensionsOfImage[0] = x;
image->Initialize(TPixel, 1, dimensionsOfImage, 1);
image->SetImportVolume(data, 0, 0, mitk::Image::CopyMemory);

mitk::IOUtil::Save(image, "C:/Users/groehl/Desktop/test.nrrd");

The same is happening with:

  • float | 2^30 values
  • long | 2^30 values
  • int | 2^30 values
  • short | 2^31 values

Event Timeline

groehl created this task.

This has most probably something to do with either memory limits of the OS (~ 4 GB is typical, especially in x86 or older versions of the OS (or even cheaper editions)), or with an integer overflow as you are operating at the very limits of 32 bit integers. Note that IOUtil must be used in a try/catch block, to operate correctly, as its error handling is completely based on exceptions.

kislinsk lowered the priority of this task from High to Normal.Mar 12 2018, 10:12 AM
kislinsk claimed this task.
kislinsk added a project: Auto-closed.

Hi there! 🙂

This task was auto-closed according to our Task Lifecycle Management.
Please follow this link for more information and don't forget that you are encouraged to reasonable re-open tasks to revive them. 🚑

Best wishes,
The MITK devs

kislinsk removed kislinsk as the assignee of this task.May 26 2020, 12:05 PM
kislinsk removed a subscriber: kislinsk.