This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
ecosconfig/cygwin work-around
- From: Bart Veer <bartv at ecoscentric dot com>
- To: ecos-patches at ecos dot sourceware dot org
- Date: 11 Jul 2006 10:35:01 +0100
- Subject: ecosconfig/cygwin work-around
This patch provides a workaround for a problem originally reported by
Drew a while back
(http://sources.redhat.com/ml/ecos-discuss/2006-02/msg00275.html) and
which does not seem to be going away with more recent versions of
cygwin. The underlying problem is convoluted. Basically the first time
a C++ exception is thrown some initialization needs to happen, which
ends up inside cygwin's pthread_key_create(). This ends up reading
location 0x4. Now, there is code in cygwin to trap and ignore that
dodgy memory access. That code seems to work fine for simple testcases
but not for ecosconfig. I do not understand why, but presumably
something in libcdl, the host-side infrastructure, or the Tcl DLL is
changing cygwin's behaviour.
Anyway, this patch causes ecosconfig to throw a C++ exception early
on. This causes the initialization to happen before any libcdl or Tcl
code gets to run, and cygwin will still ignore the access to location
0x4. Afterwards everything seems to behave normally.
A similar patch for the configtool will follow shortly, and new
prebuilts should be available from the eCosCentric devzone
(http://www.ecoscentric.com/devzone/configtool.shtml) in the near
future.
Bart
2006-07-10 Bart Veer <bartv@ecoscentric.com>
* ecosconfig.cxx: add early C++ exception throw to work around
a cygwin issue.
Index: ecosconfig.cxx
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/standalone/common/ecosconfig.cxx,v
retrieving revision 1.13
diff -u -r1.13 ecosconfig.cxx
--- ecosconfig.cxx 14 May 2003 18:16:59 -0000 1.13
+++ ecosconfig.cxx 10 Jul 2006 13:08:28 -0000
@@ -72,6 +72,12 @@
bool enable_debug_set = false; // --enable-debug or --disable-debug
int debug_level = 0; // --enable-debug=[0|1|2]
+#ifdef __CYGWIN__
+ try {
+ throw int(42);
+ } catch(...) { };
+#endif
+
Tcl_FindExecutable(argv[0]);
// getopt() cannot easily be used here since this code has to