plugins: Do not ever unload a plugin after calling into it

This is what can happen in a plugin_init function:
- An element based on GstBaseSink is registered
- Other elements fail to register
- The plugin_init function returns FALSE

Now if this the plugin is the first plugin to link against
libgstbase.so, it will have caused libgstbase.so to be loaded and static
strings from that library will have been added to gobject while
registering GstBaseSink.

So unloading the plugin will cause those strings to go stale and the
next plugin using GstBaseSink will crash. So we must not unload modules
after calling into them ever.

https://bugzilla.redhat.com/show_bug.cgi?id=572800
This commit is contained in:
Benjamin Otte 2010-03-12 16:42:47 +01:00
parent 1d316d75bb
commit 8fe63000de

View file

@ -412,18 +412,22 @@ gst_plugin_register_func (GstPlugin * plugin, const GstPluginDesc * desc,
gst_plugin_desc_copy (&plugin->desc, desc); gst_plugin_desc_copy (&plugin->desc, desc);
/* make resident so we're really sure it never gets unloaded again.
* Theoretically this is not needed, but practically it doesn't hurt.
* And we're rather safe than sorry. */
if (plugin->module)
g_module_make_resident (plugin->module);
if (user_data) { if (user_data) {
if (!(((GstPluginInitFullFunc) (desc->plugin_init)) (plugin, user_data))) { if (!(((GstPluginInitFullFunc) (desc->plugin_init)) (plugin, user_data))) {
if (GST_CAT_DEFAULT) if (GST_CAT_DEFAULT)
GST_WARNING ("plugin \"%s\" failed to initialise", plugin->filename); GST_WARNING ("plugin \"%s\" failed to initialise", plugin->filename);
plugin->module = NULL;
return NULL; return NULL;
} }
} else { } else {
if (!((desc->plugin_init) (plugin))) { if (!((desc->plugin_init) (plugin))) {
if (GST_CAT_DEFAULT) if (GST_CAT_DEFAULT)
GST_WARNING ("plugin \"%s\" failed to initialise", plugin->filename); GST_WARNING ("plugin \"%s\" failed to initialise", plugin->filename);
plugin->module = NULL;
return NULL; return NULL;
} }
} }
@ -646,7 +650,6 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
GST_PLUGIN_ERROR_MODULE, GST_PLUGIN_ERROR_MODULE,
"File \"%s\" appears to be a GStreamer plugin, but it failed to initialize", "File \"%s\" appears to be a GStreamer plugin, but it failed to initialize",
filename); filename);
g_module_close (module);
goto return_error; goto return_error;
} }