diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2015-07-29 13:32:29 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2015-07-29 13:32:29 +0200 |
commit | 6ab56bdd3f92982fcb9e7d093c3fd1b56c2b306f (patch) | |
tree | 5b2e82f0b7a5f36ae4451e0416fb8fabee626b0e /winsup/utils | |
parent | 9753bc33335b08426d6d85c5d833f40c5401c649 (diff) | |
download | newlib-6ab56bdd3f92982fcb9e7d093c3fd1b56c2b306f.zip newlib-6ab56bdd3f92982fcb9e7d093c3fd1b56c2b306f.tar.gz newlib-6ab56bdd3f92982fcb9e7d093c3fd1b56c2b306f.tar.bz2 |
cygwin: Fix crashes under AllocationPreference=0x100000 condition
* cygtls.h: Include cygtls_padsize.h and define CYGTLS_PADSIZE there.
* cygtls_padsize.h: New file. Define CYGTLS_PADSIZE.
* environ.cc (parse_options): Fix NULL pointer access.
* init.cc (threadfunc_fe): Do not force stack align on x86_64.
* strace.cc (main2): Rename from main.
(main): Make room for _cygtls area on stack and just call main2. Add
comment to explain why.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/utils')
-rw-r--r-- | winsup/utils/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/utils/strace.cc | 18 |
2 files changed, 22 insertions, 2 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index bc8835f..21a7c49 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,9 @@ +2015-07-29 Corinna Vinschen <corinna@vinschen.de> + + * strace.cc (main2): Rename from main. + (main): Make room for _cygtls area on stack and just call main2. Add + comment to explain why. + 2015-07-20 Corinna Vinschen <corinna@vinschen.de> * ldd.cc (STATUS_DLL_NOT_FOUND): Drop definition. diff --git a/winsup/utils/strace.cc b/winsup/utils/strace.cc index 4b0d669..4c0c04f 100644 --- a/winsup/utils/strace.cc +++ b/winsup/utils/strace.cc @@ -1,7 +1,7 @@ /* strace.cc Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010, 2011, 2012, 2013 Red Hat Inc. + 2009, 2010, 2011, 2012, 2013, 2015 Red Hat Inc. Written by Chris Faylor <cgf@redhat.com> @@ -26,6 +26,7 @@ details. */ #include "../cygwin/include/sys/strace.h" #include "../cygwin/include/sys/cygwin.h" #include "../cygwin/include/cygwin/version.h" +#include "../cygwin/cygtls_padsize.h" #include "path.h" #undef cygwin_internal #include "loadlib.h" @@ -1025,7 +1026,7 @@ print_version () } int -main (int argc, char **argv) +main2 (int argc, char **argv) { unsigned mask = 0; FILE *ofile = NULL; @@ -1165,6 +1166,19 @@ character #%d.\n", optarg, (int) (endptr - optarg), endptr); return 0; } +int +main (int argc, char **argv) +{ + /* Make sure to have room for the _cygtls area *and* to initialize it. + This is required to make sure cygwin_internal calls into Cygwin work + reliably. This problem has been noticed under AllocationPreference + registry setting to 0x100000 (TOP_DOWN). */ + char buf[CYGTLS_PADSIZE]; + + memset (buf, 0, sizeof (buf)); + exit (main2 (argc, argv)); +} + #undef CloseHandle static BOOL |