Description

A crash from bad memory access can happen when clearing the textures in a Texture2DArray asset.

This appears to be because the order of operations when deleting the platform data is:
```
if (PrivatePlatformData)
{
delete PrivatePlatformData;
if (PrivatePlatformData)

{ delete PrivatePlatformData; // Crash in destructor here }

PrivatePlatformData = nullptr;
}
```

This comes from the functions `UTexture2DArray::InvalidateTextureSource()` and `UTexture2DArray::SetPlatformData(...)` from Texture2DArray.cpp.

Steps to Reproduce

1. Download the Licensee's test project (see addl info URL)
2. Launch the text project with the command-line argument "-stompmalloc"
3. Open /Game/NewTexture2DArray
4. Add the texture /Game/Black to the Source Textures
5. Clear the Source Textures via the Remove All Elements button
6. Observe the memory access exception.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-216202 in the post.

0
Login to Vote

Fixed
ComponentUE - Texture
Affects Versions5.45.4.1
Target Fix5.5
Fix Commit32792787
CreatedMay 30, 2024
ResolvedMay 31, 2024
UpdatedJul 31, 2024
View Jira Issue