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

Fix malloc in filesystem_engine #1

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

chinese-soup
Copy link

Hi, this fixes the startup aborts that randomly happened and also the shutdown aborts that happened 100% of the time.

@tomkidd tomkidd merged commit 4966858 into MacSourcePorts:master Sep 12, 2023
@tomkidd
Copy link

tomkidd commented Sep 12, 2023

That explosion you're hearing is the sound of my hand smacking my forehead.

For some reason it took me months to even notice this PR and then more months to getting around to actually doing something with it. And all to discover I'm not as good with C strings as I thought.

Belated thanks for this, now I can have the bundle launch Blue Shift and Opposing Force.

image image

@tomkidd
Copy link

tomkidd commented Sep 25, 2023

@chinese-soup can you take a look at the most recent code and see if I'm doing anything wrong? I had to modify things a bit to account for the latest project changes and everything works... except now when I load it from /Applications it crashes some amount of the time with a malloc error

xash3d(55557,0x1fd9d2080) malloc: Heap corruption detected, free list is damaged at 0x600003b5c2a0
*** Incorrect guard value: 7816388778761871736
xash3d(55557,0x1fd9d2080) malloc: *** set a breakpoint in malloc_error_break to debug

The "guard value" and the hex value are different every time but it seems like it's related to the file changes again, specifically filesystem_engine.c. I ran into an issue on some Macs where it would append more than just the necessary bits so setting the value I needed to '\0' seemed to have done the trick - unless launched from the /Applications folder.

I have a feeling it's something quick/dumb but I'm not sure what.

@tomkidd
Copy link

tomkidd commented Sep 26, 2023

Odder still - it seems as if it runs fine from, say, a zip file from the Downloads folder (as in, the origin of the app bundle is a zip file and you unzip it into the Downloads folder) it is less likely to crash than, say, if it's launched from the Downloads folder but came there via a DMG, or if either ZIP or DMG versions are run from the /Applications folder. Which makes me think something it's doing or something I'm doing is upsetting a security feature in macOS, I just don't know what.

https://github.com/MacSourcePorts/xash3d-fwgs/releases/tag/v0.20-2023-09-25

Also I tried removing the line that adds '\0' and it still does the same thing.

And I just checked and yeah the version I built locally has issues in /Applications too. Very odd.

@tomkidd
Copy link

tomkidd commented Oct 1, 2023

OK yeah, figured it out - it was a different place where I needed to do the same thing. It's just that it's been so long that after all the merging I lost track of what I put in there versus what was already in there. Or at least that's the story I'm going with.

7f7c115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants