Patchwork Fix .so handling on failure

login
register
mail settings
Submitter Alexandre Lissy
Date Aug. 23, 2011, 3:19 p.m.
Message ID <1314112761-4914-2-git-send-email-alissy@mandriva.com>
Download mbox | patch
Permalink /patch/111130/
State New
Headers show

Comments

Alexandre Lissy - Aug. 23, 2011, 3:19 p.m.
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(-)

Patch

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 <alissy@mandriva.com>
+	* melt-runtime.c (melt_load_module_index): Correct handling of invalid
+	dlopen handle.
 
 2011-08-05  Basile Starynkevitch  <basile@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)