On Wed, May 12, 2010 at 02:19:08PM +0100, Graham Keeling wrote:
> On Wed, May 12, 2010 at 02:13:18PM +0100, Graham Keeling wrote:
> > On Wed, May 12, 2010 at 10:53:44PM +1000, James Harper wrote:
> > > > 
> > > > On Wed, May 12, 2010 at 10:14:52PM +1000, James Harper wrote:
> > > > > >
> > > > > > For me, both the 32 bit and 64 bit windows bacula-fd.exe 5.0.2
> > > > > downloaded from
> > > > > > bacula.org are crashing straight away.
> > > > > > That is, they crash when I try to start them. I don't get as far
> > > as
> > > > > actually
> > > > > > trying to run a backup.
> > > > > >
> > > > > > I tracked the problem down to the exchange plugin.
> > > > > > When I delete exchange-fd.dll, I can start bacula-fd.exe.
> > > > > >
> > > > > > Has anybody else had this problem?
> > > > > >
> > > > >
> > > > > Can you tell me what version of Windows and Exchange you are using?
> > > A 64
> > > > > bit version of Exchange will require a 64 bit version of Bacula, but
> > > as
> > > > > you have tried both I don't think that is your problem.
> > > > >
> > > > > In the registry there is a key called
> > > > > HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\DLLPaths
> > > containing
> > > > > a value called esebcli2. This should contain the path to the
> > > > > esebcli2.dll Exchange API. Please confirm that the registry entry
> > > > > exists, and that the DLL is where the registry says it should be.
> > > > 
> > > > None of this is relevant to the problem.
> > > > The bacula client crashes at start up, not when any backups are kicked
> > > off.
> > > 
> > > I think another post has probably identified the license mismatch error
> > > so it probably doesn't matter, but the exchange plugin loads that dll at
> > > startup and if it wasn't right it could cause a crash.
> > 
> > The licence thing looks ok to me, but I just noticed that src/lib/plugins.c
> > has changed how it closes things between 5.0.1 and 5.0.2. I'm going to try a
> > test where I use the 5.0.1 plugins.c in 5.0.2.
> 
> Yes, that has worked.

The problem is the close_plugin(Plugin *plugin) frees *plugin, but doesn't
set it to NULL.

When you have a plugin that doesn't load, the code will attempt to free *plugin
twice.

Suggested patch attached.
Index: plugins.c
===================================================================
RCS file: /cvs/netpilot/GPL/bacula-5.0.2/WORK/src/lib/plugins.c,v
retrieving revision 1.1
diff -u -r1.1 plugins.c
--- plugins.c	7 May 2010 11:05:26 -0000	1.1
+++ plugins.c	12 May 2010 14:07:05 -0000
@@ -66,21 +66,22 @@
    return plugin;
 }
 
-static void close_plugin(Plugin *plugin)
+static void close_plugin(Plugin **plugin)
 {
-   if (plugin->file) {
-      Dmsg1(50, "Got plugin=%s but not accepted.\n", plugin->file);
+   if ((*plugin)->file) {
+      Dmsg1(50, "Got plugin=%s but not accepted.\n", (*plugin)->file);
    }
-   if (plugin->unloadPlugin) {
-      plugin->unloadPlugin();
+   if ((*plugin)->unloadPlugin) {
+      (*plugin)->unloadPlugin();
    }
-   if (plugin->pHandle) {
-      dlclose(plugin->pHandle);
+   if ((*plugin)->pHandle) {
+      dlclose((*plugin)->pHandle);
    }
-   if (plugin->file) {
-      free(plugin->file);
+   if ((*plugin)->file) {
+      free((*plugin)->file);
    }
-   free(plugin);
+   free(*plugin);
+   *plugin=NULL;
 }
 
 /*
@@ -159,7 +160,7 @@
               fname.c_str(), NPRT(dlerror()));
          Dmsg2(dbglvl, "Plugin load %s failed: ERR=%s\n", fname.c_str(), 
                NPRT(dlerror()));
-         close_plugin(plugin);
+         close_plugin(&plugin);
          continue;
       }
 
@@ -170,7 +171,7 @@
             fname.c_str(), NPRT(dlerror()));
          Dmsg2(dbglvl, "Lookup of loadPlugin in plugin %s failed: ERR=%s\n", 
             fname.c_str(), NPRT(dlerror()));
-         close_plugin(plugin);
+         close_plugin(&plugin);
          continue;
       }
       plugin->unloadPlugin = (t_unloadPlugin)dlsym(plugin->pHandle, "unloadPlugin");
@@ -179,19 +180,19 @@
             fname.c_str(), NPRT(dlerror()));
          Dmsg2(dbglvl, "Lookup of unloadPlugin in plugin %s failed: ERR=%s\n",
             fname.c_str(), NPRT(dlerror()));
-         close_plugin(plugin);
+         close_plugin(&plugin);
          continue;
       }
 
       /* Initialize the plugin */
       if (loadPlugin(binfo, bfuncs, &plugin->pinfo, &plugin->pfuncs) != bRC_OK) {
-         close_plugin(plugin);
+         close_plugin(&plugin);
          continue;
       }
       if (!is_plugin_compatible) {
          Dmsg0(50, "Plugin compatibility pointer not set.\n");   
       } else if (!is_plugin_compatible(plugin)) {
-         close_plugin(plugin);
+         close_plugin(&plugin);
          continue;
       }
 
@@ -201,7 +202,7 @@
 
 get_out:
    if (!found && plugin) {
-      close_plugin(plugin);
+      close_plugin(&plugin);
    }
    if (entry) {
       free(entry);
------------------------------------------------------------------------------

_______________________________________________
Bacula-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to