From c6a6b5a3ac30a43a47aa86a36ef4feac6c34c0ce Mon Sep 17 00:00:00 2001
From: Christopher Faylor <me@cgf.cx>
Date: Wed, 24 Feb 2010 08:03:44 +0000
Subject: [PATCH] * dlfcn.cc (dlopen): Make sure exception handler is really
 loaded after dynamic load.

---
 winsup/cygwin/ChangeLog | 5 +++++
 winsup/cygwin/dlfcn.cc  | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 4d59cfbe5..3819052d2 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+2010-02-24  Christopher Faylor  <me+cygwin@cgf.cx>
+
+	* dlfcn.cc (dlopen): Make sure exception handler is really loaded after
+	dynamic load.
+
 2010-02-23  Christopher Faylor  <me+cygwin@cgf.cx>
 
 	* cygtls.cc (_cygtls::init_exception_handler): Force installation of
diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc
index e62d74cb3..a1087dba2 100644
--- a/winsup/cygwin/dlfcn.cc
+++ b/winsup/cygwin/dlfcn.cc
@@ -109,6 +109,9 @@ dlopen (const char *name, int)
 
 	  ret = (void *) LoadLibraryW (path);
 
+	  /* In case it was removed by LoadLibrary. */
+	  _my_tls.init_exception_handler (_cygtls::handle_exceptions);
+
 	  /* Restore original cxx_malloc pointer. */
 	  __cygwin_user_data.cxx_malloc = tmp_malloc;