JernejHabjan / TrumpDefense2020

Visual representation of RTS game, supported by deep reinforcement learning algorithm Alpha Zero written in python.
https://jernejhabjan.github.io/TrumpDefense2020/
MIT License
6 stars 1 forks source link

PlayerResourcesComponent nullptr exception #42

Open jacopomaroli opened 4 years ago

jacopomaroli commented 4 years ago

Describe the bug PlayerResourcesComponent member is set in the constructor of the ARTSPlayerController and gets dereferenced before hitting void ARTSPlayerController::BeginPlay() in file TrumpDefense2020\TD2020\Plugins\RealTimeStrategy\Source\RealTimeStrategy\Private\RTSPlayerController.cpp

To Reproduce Steps to reproduce the behavior:

  1. compile project
  2. run in viewport
  3. observe crash

Expected behavior It shouldn't crash

Screenshots N/A

Desktop (please complete the following information):

Additional context When you run the project from visual studio and hit the run in viewport preview mode in UE UI, you can set a breakpoint in the ARTSPlayerController constructor. This allows you to set another breakpoint when PlayerResourcesComponent variable changes (Debug-> New Breakpoint -> Data Breakpoint...: 4 bytes) This leads to a breakpoint in vcruntime140.dll!memcpy() Line 244 and if you download the debug symbols you'll find the code where it breaks is this

MoveSmall8::
        mov     rcx, qword ptr [rdx]    ; get eight bytes from source
        mov     [rax], rcx              ; write eight bytes to destination
        ret <--

with the following callstack

>   vcruntime140.dll!memcpy() Line 244  Unknown
    UE4Editor-Engine.dll!00007ffdf52c0913() Unknown
    UE4Editor-Engine.dll!00007ffdf52c0a9a() Unknown
    UE4Editor-CoreUObject.dll!00007ffdf8dea65c()    Unknown
    UE4Editor-CoreUObject.dll!00007ffdf8df3518()    Unknown
    UE4Editor-CoreUObject.dll!00007ffdf8dbf36f()    Unknown
    UE4Editor-CoreUObject.dll!00007ffdf8e09887()    Unknown
    UE4Editor-Engine.dll!00007ffdf5942726() Unknown
    UE4Editor-Engine.dll!00007ffdf5943067() Unknown
    UE4Editor-Engine.dll!00007ffdf56fa173() Unknown
    UE4Editor-Engine.dll!00007ffdf56f9f9a() Unknown
    UE4Editor-Engine.dll!00007ffdf56e39aa() Unknown
    UE4Editor-Engine.dll!00007ffdf5944325() Unknown
    UE4Editor-Engine.dll!00007ffdf5943c8c() Unknown
    UE4Editor-Engine.dll!00007ffdf56fc0c5() Unknown
    UE4Editor-UnrealEd.dll!00007ffdf377ac89()   Unknown
    UE4Editor-UnrealEd.dll!00007ffdf379b350()   Unknown
    UE4Editor-UnrealEd.dll!00007ffdf37b92e6()   Unknown
    UE4Editor-UnrealEd.dll!00007ffdf31b1891()   Unknown
    UE4Editor-UnrealEd.dll!00007ffdf3ad2346()   Unknown
    UE4Editor.exe!00007ff7966c6225()    Unknown
    UE4Editor.exe!00007ff7966d596c()    Unknown
    UE4Editor.exe!00007ff7966e48aa()    Unknown
    UE4Editor.exe!00007ff7966e659a()    Unknown
    kernel32.dll!00007ffe4c697bd4() Unknown
    ntdll.dll!00007ffe4d7ace51()    Unknown

this issue could be entirely due to ue4-rts but I thought checking with you first as it seems rather easy to incour into and it seems weird no one experienced it before.

I think it could be due to the fact that PlayerResourcesComponent gets garbage collected by UE as it's not used but that's just a wild guess based on what I read from other similar issues

TBH while compiling this issue I realized this specific commit was fiddling with something around resources so that could be the culprit... https://github.com/npruehs/ue4-rts/commit/fdcb8ae4b3810b5a9c4dbae00084404815845797 Anyhow it would be great knowing what's the hash of ue4-rts which is needed to make the project work

P.S. awesome project BTW, very inspiring. Keep it up!

JernejHabjan commented 3 years ago

Hey @jacopomaroli sorry for late response. Keep checking this project as I'm currently updating RTS dependency of https://github.com/npruehs/ue4-rts/ as a plugin. After latest version of this plugin is linked in project, errors like this should be gone. Have a good one ☺️