From f921a66d31ec25afe618900f41001472a1a9dc46 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 27 Jan 2024 19:51:59 +0000 Subject: ofz: MemorySanitizer: extend use-of-uninitialized-value bridge workaround MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I84f458b540e2e43cb3b4a06f4353e37ee2b7da2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162646 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- .../gcc3_linux_x86-64/callvirtualmethod.cxx | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'bridges') diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx index bf3e7f388108..e0bb1d54a56f 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx @@ -27,11 +27,16 @@ #include "abi.hxx" #include "callvirtualmethod.hxx" -#if defined(__has_feature) -# if __has_feature(memory_sanitizer) -# include -# define MEMORY_SANITIZER -# endif +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + +#if __has_feature(memory_sanitizer) +# include + // In the absence of a better idea just unpoison this +# define MSAN_UNPOISON_RETURN_REGISTER() __msan_unpoison(pRegisterReturn, pReturnTypeRef->pType->nSize) +#else +# define MSAN_UNPOISON_RETURN_REGISTER() #endif // The call instruction within the asm block of callVirtualMethod may throw @@ -142,30 +147,32 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod( case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: *static_cast( pRegisterReturn ) = data.rax; + MSAN_UNPOISON_RETURN_REGISTER(); break; case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: case typelib_TypeClass_ENUM: *static_cast( pRegisterReturn ) = *reinterpret_cast( &data.rax ); + MSAN_UNPOISON_RETURN_REGISTER(); break; case typelib_TypeClass_CHAR: case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: *static_cast( pRegisterReturn ) = *reinterpret_cast( &data.rax ); + MSAN_UNPOISON_RETURN_REGISTER(); break; case typelib_TypeClass_BOOLEAN: case typelib_TypeClass_BYTE: *static_cast( pRegisterReturn ) = *reinterpret_cast( &data.rax ); + MSAN_UNPOISON_RETURN_REGISTER(); break; case typelib_TypeClass_FLOAT: *static_cast(pRegisterReturn) = *reinterpret_cast(&data.xmm0); + MSAN_UNPOISON_RETURN_REGISTER(); break; case typelib_TypeClass_DOUBLE: -#if defined(MEMORY_SANITIZER) - // In the absence of a better idea just unpoison this - __msan_unpoison(&data.xmm0, sizeof(data.xmm0)); -#endif *static_cast( pRegisterReturn ) = data.xmm0; + MSAN_UNPOISON_RETURN_REGISTER(); break; default: { -- cgit