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

Stability hotfix for overrides #634

Merged
merged 3 commits into from
Dec 12, 2021
Merged

Stability hotfix for overrides #634

merged 3 commits into from
Dec 12, 2021

Conversation

psiberx
Copy link
Contributor

@psiberx psiberx commented Dec 5, 2021

  • Fixed random crashes for very frequently called overrides (such as GameObject.OnGameAttached and GameObject.OnDetach on game reload).
  • Fixed random crashes for hotkeys and inputs (for example, binding the mouse wheel had a very high chance of causing crashes).
  • Fixed potential issues when CET mods that modify TweakDB are used with TweakDBext mods at the same time.
  • Added the ability to add new free flats to TweakDB.

With more extensive use of overrides a new issue was discovered: the Lua stack could be corrupted because TiltedPhoques::Vector<sol::object> args; was placed before acquiring the lock chain.pScripting->GetState() allowing another thread in the multithreaded environment to perform garbage collection, call Lua functions, and corrupt references in args.

This leads to two possible outcomes based on what's currently on the Lua stack:

  • A call to sol::make_objec() cannot push a new value onto the stack and throw.
  • The elements of the args refer to random values on the stack and call->ScriptFunction(as_args(args)) passes the random values to the Lua handler.

@psiberx psiberx marked this pull request as draft December 6, 2021 11:37
@psiberx psiberx marked this pull request as ready for review December 12, 2021 13:49
@maximegmd maximegmd merged commit 4ed5744 into maximegmd:master Dec 12, 2021
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