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(client): Issues when updating installed plugins #5152

Conversation

Krzmbrzl
Copy link
Member

The first issue was that the old plugin would simply get overwritten
without at least warning the user that such a thing will take place.
With this commit this is still not guaranteed as plugins can be
installed in different directories in which case no warning is emitted
(the user will end up with two versions of the plugin installed in
parallel).

The second issue was that if a plugin was loaded while it is being
updated, on some OS (e.g. Windows) the corresponding library file is
locked and can thus not be overwritten. Therefore plugins are now
explicitly cleared before an overwrite is attempted.

Checks

@Krzmbrzl Krzmbrzl added client backport-needed bug A bug (error) in the software labels Jun 27, 2021
src/mumble/PluginInstaller.cpp Outdated Show resolved Hide resolved
src/mumble/PluginInstaller.cpp Outdated Show resolved Hide resolved
@hbeni
Copy link

hbeni commented Jun 27, 2021

Is there some nightly Installer I can download for testing?

@davidebeatrici
Copy link
Member

Yes, you can download it from Azure Pipelines.

@hbeni
Copy link

hbeni commented Jun 27, 2021

Yes but which one? The latest i see is from friday - is the code already there (i assume no, since its from master branch?)

@davidebeatrici
Copy link
Member

@hbeni
Copy link

hbeni commented Jun 27, 2021

Ok did a test.
In the minute reported as 20:32 i tried three times to install the plugin.
it looks like the shutdown is not initiated, at least nothing in that direction is logged.
fgcom-mumble.log

The line FGCom [2021-06-27 20:33:19.441]: Shutdown plugin was when I finally shutdown the client.


edit: When i umload the plugin manually before reinstalling, the shutdown is called.
Still, however, the same error occurs.

@Krzmbrzl
Copy link
Member Author

That's weird. The shutdown message of your plugin was always printed for me but the file still kept being locked 👀

@hbeni
Copy link

hbeni commented Jun 28, 2021

Really, weird.
Did you really see the shutdown msg from the unload, or was it from mumble-closing like i observe?

I really have no clue what could cause dll locking, but i will try to search the interwebs for it.

@davidebeatrici
Copy link
Member

bool PluginManager::clearPlugin(plugin_id_t pluginID) {
// We have to unload the plugin before we take the write lock. The reasoning being that if
// the plugin makes an API call in its shutdown callback, that'll lead to this manager being
// asked for whether a plugin with such an ID exists. The function performing this check will
// take a read lock which is not possible if we hold a write lock here already (deadlock).
unloadPlugin(pluginID);
QWriteLocker lock(&m_pluginCollectionLock);
// Remove the plugin from the list of known plugins
plugin_ptr_t plugin = m_pluginHashMap.take(pluginID);
return plugin != nullptr;
}

typedef std::shared_ptr< Plugin > plugin_ptr_t;

@Krzmbrzl Is perhaps the shared pointer being used somewhere?

@Krzmbrzl
Copy link
Member Author

Did you really see the shutdown msg from the unload, or was it from mumble-closing like i observe?

I did observe it when installing the plugin because I saw it before closing Mumble.

Is perhaps the shared pointer being used somewhere?

That was what I thought at first as well but

  1. It worked as expected with a different plugin
  2. I verified the plugin's destructor to be called and that Qt claims to have successfully unloaded the underlying library. On that note though, I did not explicitly verify that it was the fgcom plugin (but then again: it would be odd if it was a different one) 🤔

@hbeni
Copy link

hbeni commented Jun 28, 2021

Whats different at your test plugin?

@Krzmbrzl
Copy link
Member Author

Whats different at your test plugin?

I don't know. It was the ACRE2 plugin that I tested this with and with that it just worked as expected 🤷

@hbeni
Copy link

hbeni commented Jun 28, 2021

At least this tells its plugin sided.
Is there source i can look for?

@Krzmbrzl
Copy link
Member Author

@hbeni
Copy link

hbeni commented Jun 28, 2021

Ok, i opened hbeni/fgcom-mumble#131 for further tracking.
It would be cool if someone could help with this, i feel really alone with this dll locking stuff.

@Krzmbrzl
Copy link
Member Author

Krzmbrzl commented Jul 9, 2021

Okay after a fair amount of troubleshooting it turned out that the issue was indeed on the plugin's side (more specifically an issue with OpenSSL).
Now that it has been fixed the issue seems to have been resolved.

Thus I am merging this now.

The first issue was that the old plugin would simply get overwritten
without at least warning the user that such a thing will take place.
With this commit this is still not guaranteed as plugins can be
installed in different directories in which case no warning is emitted
(the user will end up with two versions of the plugin installed in
parallel).

The second issue was that if a plugin was loaded while it is being
updated, on some OS (e.g. Windows) the corresponding library file is
locked and can thus not be overwritten. Therefore plugins are now
explicitly cleared before an overwrite is attempted.
@Krzmbrzl Krzmbrzl force-pushed the fix-plugin-update-failing-due-to-lib-still-locked branch from 38b1bef to 4712665 Compare July 9, 2021 13:05
@Krzmbrzl Krzmbrzl linked an issue Jul 9, 2021 that may be closed by this pull request
3 tasks
@Krzmbrzl Krzmbrzl merged commit 10417a6 into mumble-voip:master Jul 9, 2021
@davidebeatrici
Copy link
Member

What kind of issue with OpenSSL?

@hbeni
Copy link

hbeni commented Jul 9, 2021

See here: hbeni/fgcom-mumble#131 (comment)

TLDR; the windows plugin dll got locked and not released when unloading, preventing the updater from replacing the plugin with the new version.
Cause was a change in OpenSSL which could be mitigated by adding the compile time configure option no-pinshared.

@davidebeatrici
Copy link
Member

Oh, I see. For reference: microsoft/vcpkg#12056

Krzmbrzl added a commit to Krzmbrzl/mumble that referenced this pull request Jul 12, 2021
PR mumble-voip#5152 overhauled the code for the plugin installer such that it
can completely unload a plugin before attempting to overwrite it.

However when the installer is called from the updater, that doesn't work
since the installer itself was still holding a handle to that plugin,
preventing it from unloading. Therefore this commit makes sure that the
installer releases its handle before calling the installer.

Fixes mumble-voip#4946
Krzmbrzl added a commit that referenced this pull request Jul 12, 2021
PR #5152 overhauled the code for the plugin installer such that it
can completely unload a plugin before attempting to overwrite it.

However when the installer is called from the updater, that doesn't work
since the installer itself was still holding a handle to that plugin,
preventing it from unloading. Therefore this commit makes sure that the
installer releases its handle before calling the installer.

Fixes #4946
Krzmbrzl added a commit to Krzmbrzl/mumble that referenced this pull request Jul 12, 2021
PR mumble-voip#5152 overhauled the code for the plugin installer such that it
can completely unload a plugin before attempting to overwrite it.

However when the installer is called from the updater, that doesn't work
since the installer itself was still holding a handle to that plugin,
preventing it from unloading. Therefore this commit makes sure that the
installer releases its handle before calling the installer.

Fixes mumble-voip#4946
@Krzmbrzl Krzmbrzl deleted the fix-plugin-update-failing-due-to-lib-still-locked branch November 9, 2022 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug (error) in the software client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugin Framework / Updater: possible regression
3 participants