This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] Make sure alloca is called even when optimizing, fully init _REENT
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 15 Aug 2016 09:27:10 -0000
- Subject: [newlib-cygwin] Make sure alloca is called even when optimizing, fully init _REENT
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8f1378b19fe88f562242c21109230f81bfe0519f
commit 8f1378b19fe88f562242c21109230f81bfe0519f
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Wed Jul 27 13:52:10 2016 +0200
Make sure alloca is called even when optimizing, fully init _REENT
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/init.cc | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index 1728105..5b84b1c 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -70,6 +70,10 @@ munge_threadfunc ()
void dll_crt0_0 ();
+/* Non-static fake variable so GCC doesn't second-guess if we *really*
+ need the alloca'd space in the DLL_PROCESS_ATTACH case below... */
+void *alloca_dummy;
+
extern "C" BOOL WINAPI
dll_entry (HANDLE h, DWORD reason, void *static_load)
{
@@ -85,12 +89,12 @@ dll_entry (HANDLE h, DWORD reason, void *static_load)
/* Starting with adding the POSIX-1.2008 per-thread locale functionality,
we need an initalized _REENT area even for the functions called from
- dll_crt0_0. In fact, we only need the _REENT->_locale pointer
+ dll_crt0_0. Most importantly, we need the _REENT->_locale pointer
initialized to NULL, so subsequent calls to locale-specific functions
will always fall back to __global_locale, rather then crash due to
_REENT->_locale having an arbitrary value. */
- (void) alloca (CYGTLS_PADSIZE);
- _REENT->_locale = NULL;
+ alloca_dummy = alloca (CYGTLS_PADSIZE);
+ memcpy (_REENT, _GLOBAL_REENT, sizeof (struct _reent));
dll_crt0_0 ();
_my_oldfunc = TlsAlloc ();