bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx | 25 ++++++---- 1 file changed, 16 insertions(+), 9 deletions(-)
New commits: commit f921a66d31ec25afe618900f41001472a1a9dc46 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sat Jan 27 19:51:59 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sun Jan 28 15:49:45 2024 +0100 ofz: MemorySanitizer: extend use-of-uninitialized-value bridge workaround Change-Id: I84f458b540e2e43cb3b4a06f4353e37ee2b7da2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162646 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> 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 <sanitizer/msan_interface.h> -# define MEMORY_SANITIZER -# endif +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + +#if __has_feature(memory_sanitizer) +# include <sanitizer/msan_interface.h> + // 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<sal_uInt64 *>( pRegisterReturn ) = data.rax; + MSAN_UNPOISON_RETURN_REGISTER(); break; case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: case typelib_TypeClass_ENUM: *static_cast<sal_uInt32 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt32*>( &data.rax ); + MSAN_UNPOISON_RETURN_REGISTER(); break; case typelib_TypeClass_CHAR: case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: *static_cast<sal_uInt16 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt16*>( &data.rax ); + MSAN_UNPOISON_RETURN_REGISTER(); break; case typelib_TypeClass_BOOLEAN: case typelib_TypeClass_BYTE: *static_cast<sal_uInt8 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt8*>( &data.rax ); + MSAN_UNPOISON_RETURN_REGISTER(); break; case typelib_TypeClass_FLOAT: *static_cast<float *>(pRegisterReturn) = *reinterpret_cast<float *>(&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<double *>( pRegisterReturn ) = data.xmm0; + MSAN_UNPOISON_RETURN_REGISTER(); break; default: {