GodotSteam: Exported macOS production app crashes on exit with a Segmentation Fault

First up: thank you for an excellent addon! It works nearly flawlessly and made it a breeze to add basic Steam integration and achievements to my very first game!

Description

My actual game (as well as the repro below) will run well on macOS, but after exiting the Operating System tells me the application has crashed with a “Segmentation Fault”.

Reproducible scenario

The behavior was found in my actual game (where it was also confirmed on my friend’s M2 Macbook Pro), but I’ve been able to create a very minimal repro:

  1. Create a new Godot 4 (I used 4.0.3 specifically) project on an intel-based Macbook Pro

  2. Create the most basic possible Control scene and set it as default

  3. Add the GodotSteam addon from the AssetLibrary

  4. Add var result: Dictionary = Steam.steamInit(false) to the func _ready() of the main scene

  5. Add the two Entitlements needed for Steam

    PS. You can skip these first steps if you clone my minimal repro on GitHub.

  6. Export as an .app and uncheck “Export With Debug”

  7. Start the exported app and close it

After exiting:

  • Actual result: crash report from the Operating System
  • Expected result: clean exit without errors

Abbreviated error messages, first from the Operating System (full log in the linked repo):

Process:               CrashOnExitTest001 [4721]
Path:                  /Users/USER/*/CrashOnExitTest001.app/Contents/MacOS/CrashOnExitTest001
Identifier:            org.example.godot-macos-crash-sample
Version:               1.0 (1.0)
Code Type:             X86-64 (Native)

Crashed Thread:        0  MainThrd  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000110efe640
Exception Codes:       0x0000000000000001, 0x0000000110efe640

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [4721]

VM Region Info: 0x110efe640 is not in any region.  Bytes after previous region: 1955393  Bytes before following region: 1403328
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      shared memory               110d20000-110d21000    [    4K] r--/r-- SM=SHM  
--->  GAP OF 0x334000 BYTES
      mapped file                 111055000-117650000    [102.0M] r--/rwx SM=COW  ...t_id=71773e31

Thread 0 Crashed:: MainThrd Dispatch queue: com.apple.main-thread
0   ???                           	       0x110efe640 ???
1   CrashOnExitTest001            	       0x10b1a843f 0x1080cd000 + 51229759
2   CrashOnExitTest001            	       0x10abe9f27 0x1080cd000 + 45207335
3   CrashOnExitTest001            	       0x10858d2bc 0x1080cd000 + 4981436
4   CrashOnExitTest001            	       0x1085678e0 0x1080cd000 + 4827360
5   dyld                          	    0x7ff8025d041f start + 1903

and from Godot when running with -v:

Godot Engine v4.0.3.stable.official.5222a99f5 - https://godotengine.org
TextServer: Added interface "Dummy"
TextServer: Added interface "ICU / HarfBuzz / Graphite (Built-in)"
Text-to-Speech: AVSpeechSynthesizer initialized.
Using "default" pen tablet driver...
OpenGL debugging not supported!
OpenGL API 4.1 ATI-4.12.7 - Compatibility - Using Device: ATI Technologies Inc. - AMD Radeon Pro 560X OpenGL Engine
CoreAudio: detected 2 channels
CoreAudio: audio buffer frames: 512 calculated latency: 11ms

TextServer: Primary interface set to: "ICU / HarfBuzz / Graphite (Built-in)".
CameraServer: Registered camera FaceTime HD Camera (Built-in) with ID 1 and position 0 at index 0
CORE API HASH: 0
EDITOR API HASH: 0
[S_API] SteamAPI_Init(): Loaded '/Users/jeroenheijmans/Library/Application Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/steamclient.dylib' OK.
[S_API FAIL] SteamAPI_Init() failed; no appID found.
Either launch the game from Steam, or put the file steam_appid.txt containing the correct appID in your game folder.
[S_API FAIL] Tried to access Steam interface SteamUser021 before SteamAPI_Init succeeded.
[S_API FAIL] Tried to access Steam interface SteamUtils010 before SteamAPI_Init succeeded.
{ "status": 79, "verbal": "Invalid app ID or app not installed." }
XR: Clearing primary interface
XR: Removed interfaceNative mobile
[1]    4721 segmentation fault  ./CrashOnExitTest001 -v

Additional information

Possibly important:

  • The crash-on-exit does not happen when running the application before I added GodotSteam from the asset library.
  • My repro has a few nonstandard project settings (that I thought at first would be the culprit), if needed I can try to further reduce the minimal repro by removing those
  • I’ve not yet checked if 4.1 fixes all this stuff, but I did search the recently closed issues on this repository to see if there were relevant fixes recently (and found none)
  • I encounter this on my Intel-based MBP, but the same symptom occurs in my actual game on M2 Macbooks when installing the game from Steam itself

Own research

I tried a few things to solve this issue myself before turning to an issue, for reference:

  • I’ve searched online with Google but found nearly no results, and any results I do get don’t seem relevant
  • I checked for weird logs on Windows too running with --verbose but the only minor thing I found seemed totally unrelated
  • I searched through the recently closed issues of this repository to see if there were related closed issues, but found none
  • I’ve read through the GodotSteam docs on Mac Exporting and Mac Caveats but none of the things there seemed related to “crashing on exits”. I’ve also read through the Common Issues docs, and checked the Initializing Steam docs to see if I actually needed to do some kind of cleanup or destructors or something.
  • My actual game is signed and notarized and fully accepted by macOS and Steam as such, no issues there so far
  • The Steam integration in my actual game (SHIFT+TAB overlay and Achievements) works fine, even though it seems to make the app crash on exit

Remarks

Let me know if there’s anything else I can do to assist with tackling this problem, should you have time to look at it. (And if not: that’s also fine! I appreciate that Open Source is hard work, and am already thankful for what I got to use so far! ❤️)

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 24 (14 by maintainers)

Most upvoted comments

OK, good to check all the boxes we can! Well, this seems to boil down to GDExtension and M1/M2 Macs so it is out of my league. Matches up with one other user’s issue. I’m guessing it has to do with the process used to create the plug-in. Might be missing the right stuff during creation.

I mentioned this on our staff channel to see if anyone has any ideas. I will report back when I get more information!

Haha, excellent. I guess we can close it for now but if something comes up, we’ll re-open and dig in more! Thanks for testing it!

OK, please test this on the newest release of GDExtension. We ironed out the layout for everything so this hopefully fixes it.

Im going to be taking a swing at adapting my projects GDExtension workflow to GodotSteam. Working on it here https://github.com/Trey2k/GodotSteam/tree/gdextension

No worries, I totally understand. I created the bug report to be a good community member, not because I’m personally in great need of a fix. My game was a sabbatical project and it runs great on Steam thanks to your hard open source work, and I’m super thankful for it! The one or two people playing my early access game on a Mac won’t mind a little crash window after exiting the game, it’s otherwise fully playable.

And indeed, perhaps a community member with a good Mac setup and macOS knowledge will step up to help get it fixed 🤞

PS. Also, careful, in my web development work I’ve been bit by the fact that build minutes on GitHub Actions for macOS are 5x - 10x more expensive than other OSes. Perhaps you already knew, but better safe than sorry.

Yeah, I can’t get Github Actions to work and don’t have the time to keep messing with it. Hoping someone from the community can either compile a working version for us or fix Github Actions.

I am currently working on getting our Github Actions stuff up and functional for GDExtension since I can’t seem to find anyone to compile them. Also best for instant-ish creation. Hopefully that’ll resolve these issues that you and another user are having. Hopefully. Haha.

In case it helps, my game released (for free) in Early Access on Steam even though it still has this crash on macOS. It’s also fully open source and exported from the source using Godot 4.0.x it should exhibit the bug as well.

(I’m not sure if it helps much, because the minimal repro repository from my first post is, well… more minimal. 😅)

Aye, just “New Project” from Godot 4. I did find what you meant though (I’m also not normally a macOS user, so was confused on using the Finder I guess). With these Godot docs I found the log file in this folder:

~/Library/Application Support/Godot/app_userdata/[project_name]

The godot.log file (as well as the rolled over (timestamped) ones were all completely empty. Zero bytes. I did also go to the “Project Settings” in my minimal repro to “Enable File Logging”. I’ll commit my changes and update the reproducible scenario repository in a bit too. Plus I’ll spend a little extra time to see if I can find more info here, because I expected the print(...) statement in my code to actually show at the very least in those logs.


EDIT:

I’ve added a few lines of code to the Test Button handler to ensure logs get written (some print, push_error, and other test code) and sure enough the godot.log file will get filled. But nothing useful regarding the error on exit, unfortunately. These are the contents of my recent run:

Godot Engine v4.0.3.stable.official.5222a99f5 - https://godotengine.org
TextServer: Added interface "Dummy"
TextServer: Added interface "ICU / HarfBuzz / Graphite (Built-in)"
Text-to-Speech: AVSpeechSynthesizer initialized.
Using "default" pen tablet driver...
OpenGL debugging not supported!
OpenGL API 4.1 ATI-4.12.7 - Compatibility - Using Device: ATI Technologies Inc. - AMD Radeon Pro 560X OpenGL Engine
CoreAudio: detected 2 channels
CoreAudio: audio buffer frames: 512 calculated latency: 11ms
 
TextServer: Primary interface set to: "ICU / HarfBuzz / Graphite (Built-in)".
CameraServer: Registered camera FaceTime HD Camera (Built-in) with ID 1 and position 0 at index 0
CORE API HASH: 0
EDITOR API HASH: 0
{ "status": 79, "verbal": "Invalid app ID or app not installed." }
About to throw a test exception...
USER ERROR: Test Error
   at: push_error (core/variant/variant_utility.cpp:903)
About to throw a test exception...
USER ERROR: Test Error
   at: push_error (core/variant/variant_utility.cpp:903)