TFLite Interpreter crash on Windows

When assign assign interpreter->outputs() to another variable, it crashed. Same code works fine on Linux.

#include <tensorflow/lite/kernels/register.h>
using namespace tflite;

int main() {
	std::unique_ptr<tflite::Interpreter> interpreter;
	auto model = tflite::FlatBufferModel::BuildFromFile("D:/test.tflite");
	if (model == nullptr) {
		printf("Error1\n");
	}
	tflite::ops::builtin::BuiltinOpResolver resolver;
	if (InterpreterBuilder(*model, resolver)(&interpreter) != kTfLiteOk) {
		printf("Error2\n");
	}
	if (interpreter->AllocateTensors() != kTfLiteOk) {
		printf("Error3\n");
	}

	interpreter->outputs();   // This line will work
	 //auto outs = interpreter->outputs();  // This line will crash

	printf("Done\n");
	return 0;
}

The crash is in <vector> line 559

const pointer _Rightfirst = _Right_data._Myfirst;

The exception is

Exception thrown: read access violation.
_Right_data was 0xFFFFFFFFFFFFFFF7.
1 Like

Hi @huqq1234 ,

Please provide your tflite file and the code related to the interpreter->outputs() assignment, along with any associated functions or classes, for analysing the issue. At the same time, if you’re using any custom classes with pointers make sure that objects aren’t removed before the TensorFlow Lite converter has finished processing them. It may lead to access violations.

Thank You