EXCEPTION_ACCESS_VIOLATION writing address 0x0000000080401bc0

void UHighlightManager::ClearTileColors()
{
	if (Instance == nullptr)
	{
		UE_LOG(LogHighlight, Error, TEXT("Instance is null"));
		return;
	}
	//if (Instance->TextureData == nullptr) //this isn't allowed, apparently
	//{
	//	UE_LOG(LogHighlight, Error, TEXT("Instance->TextureData is null"));
	//	return;
	//}

	for (int x = 0; x < (int)(Instance->TileSize); x++)
	{
		for (int y = 0; y < (int)(Instance->TileSize); y++)
		{
			if (Instance->TileData[x + y * (Instance->TileSize)].A == 0) continue;

			Instance->TileData[x + y * (Instance->TileSize)] = FColor(0, 0, 0, 0);
			if (!Instance->TextureData.IsValidIndex(x * 32 + (y * 32) * Instance->TextureSize)
				|| !Instance->TextureData.IsValidIndex(x * 32 + 31 + (y * 32 + 31) * Instance->TextureSize))
			{
				UE_LOG(LogHighlight, Error, TEXT("Invalid index: %d <> %d (%d, %d)"), x * 32 + (y * 32) * Instance->TextureSize, x * 32 + 31 + (y * 32 + 31) * Instance->TextureSize, x, y);
			}
			else
			{
				for (int i = 0; i < 32; i++)
				{
					for (int j = 0; j < 32; j++)
					{
						Instance->TextureData[x * 32 + i + (y * 32 + j) * Instance->TextureSize] = FColor(0, 0, 0, 0); //Crashing here
					}
				}
			}

			Instance->bHasTextureUpdate = true;
		}
	}
}

not sure what it’s failing to access; Instance, Instance->TextureData, and Instance->TextureSize are all successfully accessed before that line. Unless FColor(0, 0, 0, 0) is somehow responsible

Can you print out which iteration through the loop it’s failing on? Is it the first, last, deterministic, non-deterministic etc.?

x=0, y=0 on the two most recent repro’s. Haven’t checked i and j, as that would result in a considerable amount of spam, and the error doesn’t happen every time ClearTileColors() is called

No chance Instance is getting deleted by something else while you’re in the middle of the loop?

Might have to suffer the spam to figure this one out.

sure enough, something is destroying the HighlightManager Instance