From e00a02bdeee64e2f6380624ecddb0ead364fb7dc Mon Sep 17 00:00:00 2001 From: meli <57847713+ff-meli@users.noreply.github.com> Date: Sat, 28 Mar 2020 12:45:13 -0700 Subject: [PATCH] fix race condition with plugin render vs dispose, on Dalamud dispose. Mainly seen in crashes when using /xldclose with plugin ui open --- Dalamud/Dalamud.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index 99b1c08e5..3ed3b2ef8 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -135,6 +135,12 @@ namespace Dalamud { } public void Dispose() { + // this must be done before unloading plugins, or it can cause a race condition + // due to rendering happening on another thread, where a plugin might receive + // a render call after it has been disposed, which can crash if it attempts to + // use any resources that it freed in its own Dispose method + this.InterfaceManager.Dispose(); + try { this.PluginManager.UnloadPlugins(); @@ -146,8 +152,6 @@ namespace Dalamud { Log.Error(ex, "Plugin unload failed."); } - this.InterfaceManager.Dispose(); - this.Framework.Dispose(); this.ClientState.Dispose();