Reporting ASAN errors

Hello,

Trying to use ASAN on our end I was immediately faced with two errors caught by the tool.

This happened in Win64 Development config, compiled with clang 18.1.3 and linked with link.exe

I am adding their logs in the attached file.

1: stack use after scope

In `USlateScreenReaderEngineSubsystem::Initialize` the code takes a const reference to a TSharedRef<GenericApplication> that is obtained via an anonymous temporary object (result of `ToSharedRef`).

`IScreenReaderBuilder::FArgs Args(SlateApplication.GetPlatformApplication().ToSharedRef());`

It is then used just after to initialize other stuff, but the referenced TSharedRef has already died.

I believe the correct fix is to modify `IScreenReaderBuilder::FArgs` to store a plain TSharedRef instead of a reference. I did it locally and it fixed the error, however I did not try to use this plugin.

2: use after free

When closing our test game, an instance of `FSceneViewport` is apparently used after being freed.

Judging by the callstacks it looks like a vanilla engine issue but I can’t guarantee our code has no influence on it.

This one I did not investigate.

Hello Antoine,

Long time no see! :slight_smile:

1: Your fix seems indeed correct for the ScreenReader issue. I’ll test and submit it.

2: I wasn’t able to reproduce this one, and I don’t see how this could happen, unless ~FSceneViewport() is not called propertly at destruction time? This code does unregister a delegate (FSlateApplication::Get().GetRenderer()->OnSlateWindowDestroyed().RemoveAll(this);), and therefore, the use after free you got should not occurs, as FSceneViewport::OnWindowBackBufferResourceDestroyed should not be called.

Could you check if the FSceneViewport destruction process is correctly executed on your side?

Thanks,

Yohann

Please note that I just noticed that the first base class of FSceneViewport is FViewportFrame, which is missing its virtual destructor.

I’m curious to see if it would change anything for you if you add virtual ~FViewportFrame() = default; in it?

Hello,

Did you find anything on your side?

While stepping in FSceneViewport destructor, where you able to confirm that FSlateApplication::Get().GetRenderer()->OnSlateWindowDestroyed().RemoveAll(this); was called properly?

It would be interesting also to know which FSceneViewport (as there can be many) stays registered and if it has anything particular? Unless the same issue occurs on all FSceneViewports?

Hello,

Thanks for the update!

I contacted AMD with all the info, and I’ll keep you updated when I’ll get some news.

Hi Yohann I hope you’re doing well :slight_smile:

I’ve added the default destructor and can still reproduce. I’ll ask around if it can be linked to some patch we have on the engine.

I was able to step through FSceneViewport destructor before ASAN triggers.

In the meantime, here are ASAN details in the attached file.

Hi Yohann,

Sorry about the long delay, I’ve finally been able to get back to this.

We’ve confirmed that the issue lies in the FSR3 plugin, and does not happen when it’s disabled. https://gpuopen.com/learn/ue\-fsr3/

I am told that FFXFrameInterpolationSlateRenderer messes with Slate delegates.