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>
This commit is contained in:
Corinna Vinschen
2015-07-29 13:32:29 +02:00
parent 9753bc3333
commit 6ab56bdd3f
8 changed files with 55 additions and 13 deletions

View File

@@ -1,3 +1,10 @@
2015-07-29 Corinna Vinschen <corinna@vinschen.de>
* 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.
2015-07-23 Corinna Vinschen <corinna@vinschen.de>
* exceptions.cc (__cont_link_context): x86_64: align stack and reserve

View File

@@ -271,12 +271,7 @@ private:
};
#pragma pack(pop)
/* FIXME: Find some way to autogenerate this value */
#ifdef __x86_64__
const int CYGTLS_PADSIZE = 12800; /* Must be 16-byte aligned */
#else
const int CYGTLS_PADSIZE = 12700;
#endif
#include "cygtls_padsize.h"
/*gentls_offsets*/

View File

@@ -0,0 +1,14 @@
/* cygtls_padsize.h: Extra file to be included from utils.
Copyright 2015 Red Hat, Inc.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
/* FIXME: Find some way to autogenerate this value */
#ifdef __x86_64__
const int CYGTLS_PADSIZE = 12800; /* Must be 16-byte aligned */
#else
const int CYGTLS_PADSIZE = 12700;
#endif

View File

@@ -232,8 +232,7 @@ parse_options (const char *inbuf)
switch (k->disposition)
{
case isfunc:
k->setting.func ((!eq || !istrue) ?
k->values[istrue].s : eq);
k->setting.func ((!eq || !istrue) ? k->values[istrue].s : eq);
debug_printf ("%s (called func)", k->name);
break;
case setdword:
@@ -258,10 +257,12 @@ parse_options (const char *inbuf)
break;
}
int n = 0;
if (eq)
*--eq = ch;
int n = eq - p;
{
*--eq = ch;
n = eq - p;
}
p = strdup (keyword_here);
if (n > 0)
p[n] = ':';

View File

@@ -25,8 +25,10 @@ static bool dll_finished_loading;
static void WINAPI
threadfunc_fe (VOID *arg)
{
#ifndef __x86_64__
(void)__builtin_return_address(1);
asm volatile ("andl $-16,%%esp" ::: "%esp");
#endif
_cygtls::call ((DWORD (*) (void *, void *)) TlsGetValue (_my_oldfunc), arg);
}

View File

@@ -21,3 +21,6 @@ Bug Fixes
- Fix potential hang running ldd(1).
Addresses: https://cygwin.com/ml/cygwin/2015-07/msg00292.html
- Fix crashes under AllocationPreference=0x100000 condition
Addresses: https://cygwin.com/ml/cygwin/2015-02/msg00765.html