When an invalid handle from dlopen() was generated, the else branch
corresponding was not at the right place and was a child of
'if (!quiet_flag || flag_melt_debug)' condition. This leads to unloading
of shared library just loaded by MELT runtime when debug is not enabled,
hence the next call to mi->mmi_startrout() in
meltgc_start_module_by_index would refer to an invalid address (shared
library unloaded at the time of the call).
---
 gcc/ChangeLog.MELT |    3 +++
 gcc/melt-runtime.c |   10 +++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/ChangeLog.MELT b/gcc/ChangeLog.MELT
index f4cc6a5..4282321 100644
--- a/gcc/ChangeLog.MELT
+++ b/gcc/ChangeLog.MELT
@@ -1,3 +1,6 @@
+2011-08-23  Alexandre Lissy <ali...@mandriva.com>
+	* melt-runtime.c (melt_load_module_index): Correct handling of invalid
+	dlopen handle.
 
 2011-08-05  Basile Starynkevitch  <bas...@starynkevitch.net>
 	* melt-runtime.c (melt_run_make_for_plugin): Don't use fullbinfile.
diff --git a/gcc/melt-runtime.c b/gcc/melt-runtime.c
index 8eea8f1..ca580a4 100644
--- a/gcc/melt-runtime.c
+++ b/gcc/melt-runtime.c
@@ -8764,11 +8764,11 @@ melt_load_module_index (const char*srcbase, const char*flavor)
 		  MELTDESCR_REQUIRED(melt_gen_timestamp), 
 		  MELTDESCR_REQUIRED(melt_build_timestamp));
       }
-      else 
-	{
-	  debugeprintf ("melt_load_module_index invalid dlh %p sopath %s", dlh, sopath);
-	  dlclose (dlh), dlh = NULL;
-	}
+    }
+    else 
+    {
+	debugeprintf ("melt_load_module_index invalid dlh %p sopath %s", dlh, sopath);
+	dlclose (dlh), dlh = NULL;
     }
  end:
   if (srcpath) 

Reply via email to