bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx | 65 +++++----- sal/osl/unx/thread.c | 17 +- 2 files changed, 50 insertions(+), 32 deletions(-)
New commits: commit 85dc388993beca806b5a7ec91c9c49172b3a781b Author: Stephan Bergmann <sberg...@redhat.com> Date: Wed May 21 09:02:43 2014 +0200 Default OS X thread stack size too small for -fsanitize=address ...witnessed stack overflow in huge function FunctionMapFactory::createFunctionMap__library_effects__allChildren in workdir/UnpackedTarball/opencollada/COLLADASaxFrameworkLoader/src/generated14/ COLLADASaxFWLColladaParserAutoGen14PrivateFunctionMapFactory.cpp Change-Id: I9451912043e282c8e06aff446cf3d1190f1de9cf diff --git a/sal/osl/unx/thread.c b/sal/osl/unx/thread.c index 0140936..5335dd6 100644 --- a/sal/osl/unx/thread.c +++ b/sal/osl/unx/thread.c @@ -22,6 +22,7 @@ #if defined(OPENBSD) #include <sched.h> #endif +#include <config_options.h> #include <osl/diagnose.h> #include <osl/thread.h> #include <osl/nlsupport.h> @@ -251,8 +252,9 @@ static oslThread osl_thread_create_Impl ( short nFlags) { Thread_Impl* pImpl; -#if defined(OPENBSD) +#if defined OPENBSD || (defined MACOSX && !ENABLE_RUNTIME_OPTIMIZATIONS) pthread_attr_t attr; + size_t stacksize; #endif int nRet=0; @@ -266,11 +268,16 @@ static oslThread osl_thread_create_Impl ( pthread_mutex_lock (&(pImpl->m_Lock)); -#if defined(OPENBSD) +#if defined OPENBSD || (defined MACOSX && !ENABLE_RUNTIME_OPTIMIZATIONS) if (pthread_attr_init(&attr) != 0) return (0); - if (pthread_attr_setstacksize(&attr, 262144) != 0) { +#if defined OPENBSD + stacksize = 262144; +#else + stacksize = 100 * PTHREAD_STACK_MIN; +#endif + if (pthread_attr_setstacksize(&attr, stacksize) != 0) { pthread_attr_destroy(&attr); return (0); } @@ -278,7 +285,7 @@ static oslThread osl_thread_create_Impl ( if ((nRet = pthread_create ( &(pImpl->m_hThread), -#if defined(OPENBSD) +#if defined OPENBSD || (defined MACOSX && !ENABLE_RUNTIME_OPTIMIZATIONS) &attr, #else PTHREAD_ATTR_DEFAULT, @@ -295,7 +302,7 @@ static oslThread osl_thread_create_Impl ( return (0); } -#if defined(OPENBSD) +#if defined OPENBSD || (defined MACOSX && !ENABLE_RUNTIME_OPTIMIZATIONS) pthread_attr_destroy(&attr); #endif commit 00468b48e8678d819a8e34be8c1e256ce36c1396 Author: Stephan Bergmann <sberg...@redhat.com> Date: Wed May 21 08:55:48 2014 +0200 Work around Clang -fsanitize=address inline asm error same as 08947735f9cc4b7bd69676c9dd4d1700e8e3b15b for gcc_linux_x86-64 Change-Id: I28d138dd13adc9a3e09d46befe69ac86ab1fffb6 diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx index 3b6cd4a..971ca8a 100644 --- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx +++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx @@ -57,10 +57,27 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod( if ( nGPR > x86_64::MAX_GPR_REGS ) nGPR = x86_64::MAX_GPR_REGS; + // Work around -fsanitize=address "inline assembly requires more registers + // than available" error: + struct Data { + sal_uInt64 pMethod; + sal_uInt64 * pGPR; + double * pFPR; + sal_uInt64 nFPR; + // Return values: + sal_uInt64 rax; + sal_uInt64 rdx; + double xmm0; + double xmm1; + } data; + data.pGPR = pGPR; + data.pFPR = pFPR; + data.nFPR = nFPR; + // Get pointer to method sal_uInt64 pMethod = *((sal_uInt64 *)pThis); pMethod += 8 * nVtableIndex; - pMethod = *((sal_uInt64 *)pMethod); + data.pMethod = *((sal_uInt64 *)pMethod); // Load parameters to stack, if necessary if ( nStack ) @@ -71,16 +88,10 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod( std::memcpy( pCallStack, pStack, nStackBytes ); } - // Return values - sal_uInt64 rax; - sal_uInt64 rdx; - double xmm0; - double xmm1; - asm volatile ( // Fill the xmm registers - "movq %6, %%rax\n\t" + "movq 16%0, %%rax\n\t" "movsd (%%rax), %%xmm0\n\t" "movsd 8(%%rax), %%xmm1\n\t" @@ -92,7 +103,7 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod( "movsd 56(%%rax), %%xmm7\n\t" // Fill the general purpose registers - "movq %5, %%rax\n\t" + "movq 8%0, %%rax\n\t" "movq (%%rax), %%rdi\n\t" "movq 8(%%rax), %%rsi\n\t" @@ -102,45 +113,45 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod( "movq 40(%%rax), %%r9\n\t" // Perform the call - "movq %4, %%r11\n\t" - "movq %7, %%rax\n\t" + "movq 0%0, %%r11\n\t" + "movq 24%0, %%rax\n\t" "call *%%r11\n\t" // Fill the return values - "movq %%rax, %0\n\t" - "movq %%rdx, %1\n\t" - "movsd %%xmm0, %2\n\t" - "movsd %%xmm1, %3\n\t" - : "=m" ( rax ), "=m" ( rdx ), "=m" ( xmm0 ), "=m" ( xmm1 ) - : "m" ( pMethod ), "m" ( pGPR ), "m" ( pFPR ), "m" ( nFPR ) + "movq %%rax, 32%0\n\t" + "movq %%rdx, 40%0\n\t" + "movsd %%xmm0, 48%0\n\t" + "movsd %%xmm1, 56%0\n\t" + :: "o" (data) : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", - "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" + "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15", + "memory" ); switch (pReturnTypeRef->eTypeClass) { case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: - *reinterpret_cast<sal_uInt64 *>( pRegisterReturn ) = rax; + *reinterpret_cast<sal_uInt64 *>( pRegisterReturn ) = data.rax; break; case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: case typelib_TypeClass_ENUM: - *reinterpret_cast<sal_uInt32 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt32*>( &rax ); + *reinterpret_cast<sal_uInt32 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt32 *>( &data.rax ); break; case typelib_TypeClass_CHAR: case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: - *reinterpret_cast<sal_uInt16 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt16*>( &rax ); + *reinterpret_cast<sal_uInt16 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt16 *>( &data.rax ); break; case typelib_TypeClass_BOOLEAN: case typelib_TypeClass_BYTE: - *reinterpret_cast<sal_uInt8 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt8*>( &rax ); + *reinterpret_cast<sal_uInt8 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt8 *>( &data.rax ); break; case typelib_TypeClass_FLOAT: case typelib_TypeClass_DOUBLE: - *reinterpret_cast<double *>( pRegisterReturn ) = xmm0; + *reinterpret_cast<double *>( pRegisterReturn ) = data.xmm0; break; default: { @@ -148,12 +159,12 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod( if (bSimpleReturn && nRetSize <= 16 && nRetSize > 0) { sal_uInt64 longs[2]; - longs[0] = rax; - longs[1] = rdx; + longs[0] = data.rax; + longs[1] = data.rdx; double doubles[2]; - doubles[0] = xmm0; - doubles[1] = xmm1; + doubles[0] = data.xmm0; + doubles[1] = data.xmm1; x86_64::fill_struct( pReturnTypeRef, &longs[0], &doubles[0], pRegisterReturn); } break; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits