Custom class that contains std::list in Unreal Containers for Nintendo Switch

I am currently doing a project in unreal engine 5.1 in various platforms: ps, pc, xbox, switch. I faced a problem that only occurs in nintendo switch, and I found the cause by testing this code in new project.

Let’s say i have a 3 classes and call function Test();

struct TestProdStruct
{
	int32 prod;
	int32 opt;

	TestProdStruct()
	{
		prod = 0;
		opt = 0;
	}
};

struct TestListStruct
{
	int listnum;
	std::list<TestProdStruct> TestProdList;

	TestListStruct()
	{
		listnum = 0;
		TestProdList.clear();
	}
};

struct TestStruct
{
	int evcode;

	std::list<TestListStruct> TestList;

	TestStruct()
	{
		evcode = 0;
		TestList.clear();
	}
};


void SwitchTestClass::Test()
{
	TestStruct A, B, C, D, E;
	A.evcode = 1;
	B.evcode = 2;
	C.evcode = 3;
	D.evcode = 4;
	E.evcode = 5;

	TArray<TestStruct> ArrTest;
	ArrTest.Add(A);
	ArrTest.Add(B);
	ArrTest.Add(C);
	ArrTest.Add(D);
	ArrTest.Add(E);
	
	//v1
	for (const auto& tester : ArrTest)
	{
		for (const auto& testlist : tester.TestList)
		{
			for (const auto& prodlist : testlist.TestProdList)
			{
				int32 evcode = tester.evcode;
				int32 prod = prodlist.prod;
				int32 opt = prodlist.opt;
				UE_LOG(LogTemp, Warning, TEXT("evcode = %d, prod = %d, opt = %d"), evcode, prod, opt);
			}
		}
	}

	//v2
	for (const auto& tester : ArrTest)
	{
		for (const auto& testlist : tester.TestList)
		{
			int32 evcode = tester.evcode;
			int32 listnum = testlist.listnum;
			
			UE_LOG(LogTemp, Warning, TEXT("evcode = %d, listnum = %d"), evcode, listnum);
		}
	}
}

I have two versions of code inside function Test(). If I go through v1, it crashes with access violation to memory. Going through v2, the code will infinite loop at the first element of ArrTest. The problem only happens after adding the 5th element, where the ResizeAllocation of TArray happens.

This problem also occurs when using TMap rather than TArray, but the problem is fixed when I use std::map or std::vector.

Why is this Happening?

Its just my prediction, the std::list in nintendo switch have embedded sentinel, where the other platforms have external sentinel. When I debugged the code, I found out that begin() and end() won’t match each other even though the size of the list was 0, or just loop infinitely when size is over 0. So after the ResizeAllocation the memory address changed causing problem. If the list have external sentinel, the begin() end() is kept outside the box and memory change won’t affect their address, but embedded sentinel will have it’s end() or begin() (depends on platform) change and the list is corrupted.

Can somebody tell me if my prediction is correct, and if it is or isn’t, teach me a solution to avoid my list getting corrupted? I can’t change lot from my original code because it is being used at many other codes and will have a big side effect. However if it necessary to fix codes, I can still work on it. Thank You.