#GEngine->AddOnScreenDebugMessage() throws Access Violation

10 messages · Page 1 of 1 (latest)

hollow grail
#

Hello, I'm on lesson 9 (Accessing the Online Subsystem), and I'm getting a build-time error when I try to print the name of the online subsystem:

Exception has occurred: W32/0xC0000005
Unhandled exception at 0x00007FFFDA53CE6F (UnrealEditor-Engine.dll) in UnrealEditor.exe: 0xC0000005: Access violation reading location 0x0000000000000EB8.

Some search results I've seen suggest this is related to multi-threading and load order. I'm building the game, which launches UnrealEditor, and it seems GEngine isn't ready by the time my constructor is called along with AddOnScreenDebugMessage().

Has anyone run into this? Are there any simple solutions to make this work? Thanks!

#

The line of code this exception points to is this:

GEngine->AddOnScreenDebugMessage(

The full context of the above call is this:

GEngine->AddOnScreenDebugMessage(
  -1,
  15.f,
  FColor::Purple,
  FString::Printf(TEXT("Online subsystem: %s"), *OnlineSubsystem->GetSubsystemName().ToString())
);
#

Unfortunately there's no resolution there. I'm just going to skip debug printing in the meantime so I can continue.

dull sleet
#

@hollow grail Yeah m80 you can't use GEngine in the ctor as GEngine doesn't exist yet. Use UE_LOG or GLog

#

You realize the ctor is called outside running the game? And GEngine exists within the context of when it's running, so that's why you can't do that. Just log it out

hollow grail
#

Yeah that makes perfect sense. The above code was copied straight from the lesson 9 video, so we may want to update that 🙂

#

Thanks!

dull sleet
# hollow grail Thanks!

Very welcome. Lol tbh I learned that the hard way lol by crashing the engine like what happened to you 😂

#

Then I figured out that you can just log it out