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

objmem: prevent calling audio_RemoveObj() from the destructors of in-game objects #4033

Merged

Conversation

ManManson
Copy link
Member

The call to audio_RemoveObj inside the destructors of SIMPLE_OBJECT, DROID, STRUCTURE, FEATURE and PROJECTILE classes can possibly invoke undefined behavior if the warzone process is being forcefully shut down (either by us, the user or some other third-party code, like X11 in case of linux).

The reason for this is that by the time a given game object is being destroyed, chances are that the static objects from the audio code, which are being accessed by the audio_RemoveObj(), can already be destroyed (due to the inverse of the Static initialization order fiasco).

Signed-off-by: Pavel Solodovnikov [email protected]

@past-due past-due added this to the 4.5.2 milestone Aug 10, 2024
@ManManson ManManson force-pushed the fix-audio-remove-obj-segfaults branch from cbba9a9 to e3bd297 Compare August 10, 2024 17:34
@ManManson
Copy link
Member Author

Adjusted the code to compile in C++14 mode + fixed potential use-after-move in detail::for_each_tuple_impl recursive helper.

@ManManson ManManson force-pushed the fix-audio-remove-obj-segfaults branch 3 times, most recently from 8aec60a to 090a732 Compare August 11, 2024 08:30
…-game objects

The call to `audio_RemoveObj` inside the destructors of
`SIMPLE_OBJECT`, `DROID`, `STRUCTURE`, `FEATURE` and `PROJECTILE`
classes can possibly invoke undefined behavior if the
warzone process is being forcefully shut down.

The reason for this is that by the time a given game object
is being destroyed, chances are that the static objects
from the audio code, which are being accessed by the
`audio_RemoveObj()`, can already be destroyed (due to the inverse
of the [Static initialization order fiasco](https://en.cppreference.com/w/cpp/language/siof)).

Signed-off-by: Pavel Solodovnikov <[email protected]>
@ManManson ManManson force-pushed the fix-audio-remove-obj-segfaults branch from 090a732 to 97fc9e5 Compare August 11, 2024 08:36
@past-due past-due merged commit ad6a918 into Warzone2100:master Aug 11, 2024
37 checks passed
@ManManson ManManson deleted the fix-audio-remove-obj-segfaults branch August 11, 2024 17:12
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