OpenXRay / xray-16

Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World. Join OpenXRay! ;)
https://discord.gg/sjRMQwv
Other
2.9k stars 455 forks source link

[macOS] Segfault on quit #1651

Open shinra-electric opened 3 months ago

shinra-electric commented 3 months ago

Describe the bug OpenXRay will segfault when trying to quit, either via in-game menu or Command+Q

If the game is run from the command line, closing the terminal window may force-quit it. But if the app is run from an app bundle, trying to force-quit or kill -9 PID doesn't work and a restart is required.

To Reproduce Try to quit the game

Expected behavior It should quit cleanly

BugTrap error report Terminal Saved Output.txt

Desktop (please complete the following information):

AMS21 commented 3 months ago

Possible duplicate of #1586 although that one is for Linux and not macOS

Xottab-DUTY commented 2 months ago

The issue should have been fixed, please test!

Duplicate of #1586.

shinra-electric commented 2 months ago

Yes, it quits properly now. Thanks!

shinra-electric commented 2 months ago

Actually, the issue is not fully fixed.

I was able to quit successfully when on the game menu, but I just tried quitting from in-game and got another segfault.

Terminal Saved Output.txt

Xottab-DUTY commented 2 months ago

Actually, the issue is not fully fixed.

I was able to quit successfully when on the game menu, but I just tried quitting from in-game and got another segfault.

Terminal Saved Output.txt

That is another issue, not related to #1586 then (though, with similar reasons and symptoms). I'll remove "duplicate" label and reopen this issue to track it.

Xottab-DUTY commented 2 months ago

@shinra-electric, please, test it now with the latest dev branch.

In f97fedda4db7661128cf0fae2098391d499e5366 I've made the changes that should hide the crash from the user. At least, xrDebug window won't be shown, but I guess you still may see something in the terminal.

Xottab-DUTY commented 2 months ago

Actually, the issue is not fully fixed.

I was able to quit successfully when on the game menu, but I just tried quitting from in-game and got another segfault.

Terminal Saved Output.txt

Stack trace for me:

xrDebug::GatherInfo(char*, unsigned long, ErrorLocation const&, char const*, char const*, char const*, char const*)
xrDebug::Fail(bool&, ErrorLocation const&, char const*, char const*, char const*, char const*)
segmentation_fault_handler(int)
3   libsystem_platform.dylib            0x00000001971bf584 _sigtramp + 56
4   ???                                 0xffff8001970ba8a8 0x0 + 18446603343050287272
std::__1::recursive_mutex::lock()
ScopeLock::ScopeLock(Lock*)
ISpatial_DB::remove(ISpatial*)
SpatialBase::spatial_unregister()
light::~light()
std::__1::vector<resptr_core<IRender_Light, resptrcode_light>, xalloc<resptr_core<IRender_Light, resptrcode_light>>>::__destroy_vector::operator()[abi:ue170006]()
CLight_DB::~CLight_DB()
CRender::~CRender()
13  libsystem_c.dylib                   0x000000019704bf2c __cxa_finalize_ranges + 476
14  libsystem_c.dylib                   0x000000019704bcb4 exit + 44
dyld4::LibSystemHelpers::getenv(char const*) const
16  dyld                                0x0000000196e0612c start + 2436
! Failed to copy text to the clipboard: Video subsystem must be initialized to set clipboard text

The reason is that, during Device.Destroy(), not all renderer elements are destroyed. (almost similar to #804, but e.g. there's no function that clears LightsDB)

shinra-electric commented 2 months ago

After trying again I get a crash on launch:

crash_report.txt

But I've noticed that there have been many changes since I tried it last, so it may be unrelated to the crash fix PR.

Xottab-DUTY commented 2 months ago

After trying again I get a crash on launch:

crash_report.txt

But I've noticed that there have been many changes since I tried it last, so it may be unrelated to the crash fix PR.

What's the log from the engine?

shinra-electric commented 2 months ago

The error was Can't setup renderer

terminal_output.txt

Xottab-DUTY commented 2 months ago

The error was Can't setup renderer

terminal_output.txt

The reason why full log is needed is because the error Can't setup renderer is not the reason of the error (sounds funny :)), while the reason is stated somewhere in the log. So, yea, the reason is this:

~ Cannot create helper window for OpenGL: NSWindow should only be instantiated on the main thread!

I've added multithreaded renderer library initialization, it works on Windows, but does not work on Linux. Will fix.

Xottab-DUTY commented 1 month ago

@shinra-electric, I've fixed that issue, please, test it again!

shinra-electric commented 1 month ago

Same error with NSWindow:

terminal output.txt

Xottab-DUTY commented 1 month ago

Same error with NSWindow:

terminal output.txt

Fixed.

shinra-electric commented 1 month ago

The NSWindow error is gone, but it's still crashing on launch:

terminal output.txt

shinra-electric commented 1 month ago

Just for further information, this log has more information about the crash on launch:

Terminal Saved Output.txt