Crash when configuration conflict (library debug & vtk release)

I’m running into an odd error that I can’t seem to figure out the reason behind. With the following code I get a crash when compiling release mode, but it runs totally fine in debug mode.

I’m working with vtk 9.2 libraries. I’ll compile the latest to see if this is also an issue, however I’m version limited on the system this will be deployed to.

	vtkNew<vtkUnstructuredGrid> test_grid;
	test_grid->SetPoints(vtkSmartPointer<vtkPoints>::New());

	test_grid->GetPoints()->InsertNextPoint(0., 0., 0.);
	test_grid->GetPoints()->InsertNextPoint(1., 0., 0.);
	test_grid->GetPoints()->InsertNextPoint(1., 1., 0.);
	test_grid->GetPoints()->InsertNextPoint(0., 1., 0.);

	const vtkIdType pntsIds[] = {0,1,2,3};
	test_grid->InsertNextCell(VTK_POLYGON, 4, pntsIds);

	vtkSmartPointer<vtkFloatArray> scalar = vtkSmartPointer<vtkFloatArray>::New();
	scalar->SetName("field_value1");
	scalar->InsertNextValue(5);
	test_grid->GetCellData()->AddArray(scalar); //Crashes here

The crash inside of vtk seems to originate here:

void vtkFieldData::AllocateArrays(int num)
{
...
  }
  else // num > this->NumberOfArrays
  {
    vtkAbstractArray** data = new vtkAbstractArray*[num];
    this->Ranges.resize(num);
    this->FiniteRanges.resize(num);  //<<--- Here

Basically all the variables of this instance are garbage (Ranges, FiniteRanges, NumberOfArrays, etc.)

When compiled in debug mode, these are all empty/0.

I’m stumped. Can anyone suggest where to look?

A bit of further information I just discovered.

The crash appears to be an issue between the Release/Debug compilation. Below table represents what I’ve been able to reproduce.

my_library vtk crash?
debug debug 0
release debug 1
debug release 1
release release 0

Can anyone give reasoning why this is happening?

In order to resolve this I would have to have both debug and release versions of the vtk libraries when developing. Which, for me is no issue, but for the others on my team who won’t be touching this part of the code it’s a bit of a pain to manage.