Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 128 character buffer causing long filenames to crash gk #3771

Merged
merged 2 commits into from
Nov 28, 2024

Conversation

massimilianodelliubaldini
Copy link
Contributor

@massimilianodelliubaldini massimilianodelliubaldini commented Nov 19, 2024

Several users have reported that ArchipelaGOAL is not launching properly, even when using the OpenGOAL Launcher. The window pops up with a black screen, and then quits. The only way they can run it is if they double click gk.exe.

This comes down to the Launcher providing gk.exe with the config_path parameter, which leads the program to find archipelagoal-settings.gc. Here is an example from me:

D:\Applications\Games\OpenGOAL\features\jak1\mods\JakMods\_settings\archipelagoal\OpenGOAL\jak1\settings/Mods/archipelagoal-settings.gc

If a user's base OpenGOAL install directory is long enough, this path becomes longer than 128 characters. This overflows the character buffer in kopen which is used to open file streams. If you're only slightly over the limit like myself, at 135 characters, you may not have noticed a problem. But some users have paths a little longer, like 168 characters, and they report the issue is consistent.

Water111 suggested we remove the 128 character buffer and use the filename data directly. This fix requires no changes to the Launcher, just to the kernel, and every mod could stand to benefit from this fix.

@OpenGOALBot
Copy link
Collaborator

Can one of the admins verify this patch?

@massimilianodelliubaldini
Copy link
Contributor Author

massimilianodelliubaldini commented Nov 19, 2024

Before Test

I verified the issue is reproducible with the following command:

D:\Files\Repositories\ArchipelaGOAL-But-Its-Way-Too-Long-For-Windows\out\build\Release\bin\gk.exe -v --game jak1 --config-path D:\Files\Repositories\ArchipelaGOAL-But-Its-Way-Too-Long-For-Windows\out\build\Release\_settings\archipelagoal -- -boot -fakeiso

Here are the last few console lines, showing the app halting right as it tries to run kopen.

Resetting archipelago settings                                                           x1cd5a31
[Archipelago] Settings found at 'D:\Files\Repositories\ArchipelaGOAL-But-Its-Way-Too-Long-For-Windows\out\build\Release\_settings\archipelagoal\OpenGOAL\jak1\settings/Mods/archipelagoal-settings.gc'... loading!
****** CALL TO kopen() ******
D:\Files\Repositories\ArchipelaGOAL-But-Its-Way-Too-Long-For-Windows [main ↑78]>

After Test

I'll now rename my repository folder back to what it was so I can rebuild gk with the fix. Once it is done building, I will rename the folder back to being way too long, and try running the same command with the same arguments. If the fix works, the program should no longer halt when it tries to load the archipelagoal settings file.

Indeed, the game now boots in retail mode correctly with the same command as before. I've also verified that the settings file is being read correctly, as the options I expect to see in-game are there. Here are the few console lines that come after reading the too-long archipelago settings file path:

Resetting archipelago settings
[Archipelago] Settings found at 'D:\Files\Repositories\ArchipelaGOAL-But-Its-Way-Too-Long-For-Windows\out\build\Release\_settings\archipelagoal\OpenGOAL\jak1\settings/Mods/archipelagoal-settings.gc'... loading!
****** CALL TO kopen() ******
Archipelago settings file read: "D:\Files\Repositories\ArchipelaGOAL-But-Its-Way-Too-Long-For-Windows\out\build\Release\_settings\archipelagoal\OpenGOAL\jak1\settings/Mods/archipelagoal-settings.gc"
pc settings reset
Setting window size to 640 x 480
[PC Settings]: Valid default game-size resolution set 3440 x 1440
[PC Settings]: fullscreen resolution defaulted to 3440 x 1440
[PC] PC Settings found at 'D:\Files\Repositories\ArchipelaGOAL-But-Its-Way-Too-Long-For-Windows\out\build\Release\_settings\archipelagoal\OpenGOAL\jak1\settings/pc-settings.gc'...loading!
****** CALL TO kopen() ******
[PC Settings]: Valid game-size resolution 3440 x 1440
pc settings file read: "D:\Files\Repositories\ArchipelaGOAL-But-Its-Way-Too-Long-For-Windows\out\build\Release\_settings\archipelagoal\OpenGOAL\jak1\settings/pc-settings.gc"     
[05:09] [debug] [link and exec] input-display      0  16611 heap-use 29051616        0: 0x1cf4800

If there's another test I should do, perhaps a negative test, let me know!

@xTVaser
Copy link
Member

xTVaser commented Nov 19, 2024

add to whitelist

Copy link
Collaborator

@water111 water111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@water111 water111 merged commit 4c2e1a8 into open-goal:master Nov 28, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants