Unhandled Exception and Crash in Fortnite

Reference ID

10d11f1a-4b2a-f5c2-0d30-c09bb1533952

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Summary

When using a cancelable object in Verse and attempting to use it later in a spawn coroutine, an unhandled exception occurs, leading to crash in fortnite, but uefn report nothing.

Fatal error!

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x000000000000002c

0x00007ff7142c9953 FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff7142c908c FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff716eb1af4 FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff7142c9a4b FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff7142c908c FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff7154bd687 FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff7154bd5f8 FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff7141ea243 FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff7141ea875 FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff7140ef51a FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff7140ee44a FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff7140eef71 FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff714dc78ef FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff714dc7752 FortniteClient-Win64-Shipping.exe!UnknownFunction []
0x00007ff8810d257d KERNEL32.DLL!UnknownFunction []

Steps to Reproduce

  • Start on a fresh island.
  • Use the reproduce_device and populate a player spawner.
  • Launch the session.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }

reproduce_device := class(creative_device):
    @editable
    PlayerSpawner: player_spawner_device = player_spawner_device{}

    OnBegin<override>()<suspends>:void=
        PlayerSpawner.SpawnedEvent.Subscribe(OnPlayerSpawed)

    OnPlayerSpawed(Agent: agent):void=
        if(Char:=Agent.GetFortCharacter[]):
            C := Char.EliminatedEvent().Subscribe(OnPlayerEliminated)
            #Not Safe
            spawn:
                AwaitPlayerEliminated(Char, C)

    #Not Safe
    AwaitPlayerEliminated(Character: fort_character, Cancelable : cancelable)<suspends>:void=
        Character.EliminatedEvent().Await()
        Sleep(1.0)
        Cancelable.Cancel()
    #Not Safe

    OnPlayerEliminated(ER: elimination_result):void=
        Print("Eliminated", ?Duration:=6.0)

Expected Result

No crash or report error in uefn

Observed Result

It appears that the cancelable object gets garbage collected before use, resulting in a use-after-free exception. This issue occurs specifically when launching a fresh session from UEFN or pushing to an edit session. However, it does not happen when pushing only verse code.

Platform(s)

windows

I’ve encountered an issue related to the cancelable object in Verse code. When used within a spawn coroutine, it leads to an unhandled exception and game crash. UEFN doesn’t report this issue. Please investigate. Thank you