[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - external/firebird

Tor Lillqvist tml at collabora.com
Mon Jun 18 12:33:24 UTC 2018


 external/firebird/UnpackedTarball_firebird.mk |    1 
 external/firebird/macos-segv-fix.patch        |  113 ++++++++++++++++++++++++++
 2 files changed, 114 insertions(+)

New commits:
commit 21b6a6c0dcf536b539be107e930d63faaefbf5d3
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Jun 18 12:20:01 2018 +0300

    Back-port of essential bits of Stephan's Firebird macOS alignment crack fix
    
    Fixes the SEGV from isql ("Segmentation fault: 11") during 'make
    firebird' for me.
    
    Change-Id: Ie912932d07299ef39b96d833aaadf7c9ebbb8520
    Reviewed-on: https://gerrit.libreoffice.org/56033
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/external/firebird/UnpackedTarball_firebird.mk b/external/firebird/UnpackedTarball_firebird.mk
index f0cc5aea01b6..31a3ea53d7df 100644
--- a/external/firebird/UnpackedTarball_firebird.mk
+++ b/external/firebird/UnpackedTarball_firebird.mk
@@ -28,6 +28,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,firebird,\
 		external/firebird/libc++.patch \
 		external/firebird/0001-Avoid-hangup-in-SS-when-error-happens-at-system-atta.patch.1 \
 		external/firebird/0002-Backported-fix-for-CORE-5452-Segfault-when-engine-s-.patch.1 \
+		external/firebird/macos-segv-fix.patch \
 ))
 
 ifeq ($(OS),WNT)
diff --git a/external/firebird/macos-segv-fix.patch b/external/firebird/macos-segv-fix.patch
new file mode 100644
index 000000000000..4fde075d1665
--- /dev/null
+++ b/external/firebird/macos-segv-fix.patch
@@ -0,0 +1,113 @@
+--- src/common/classes/alloc.cpp
++++ src/common/classes/alloc.cpp
+@@ -2187,7 +2187,7 @@
+ 
+ void* MemPool::allocRaw(size_t size) throw (OOM_EXCEPTION)
+ {
+-#ifndef USE_VALGRIND
++#if !(defined USE_VALGRIND || defined USE_ASAN)
+ 	if (size == DEFAULT_ALLOCATION)
+ 	{
+ 		MutexLockGuard guard(*cache_mutex, "MemPool::allocRaw");
+@@ -2267,7 +2267,7 @@
+ 
+ void MemPool::releaseRaw(bool destroying, void* block, size_t size, bool use_cache) throw ()
+ {
+-#ifndef USE_VALGRIND
++#if !(defined USE_VALGRIND || defined USE_ASAN)
+ 	if (use_cache && (size == DEFAULT_ALLOCATION))
+ 	{
+ 		MutexLockGuard guard(*cache_mutex, "MemPool::releaseRaw");
+@@ -2277,7 +2277,7 @@
+ 			return;
+ 		}
+ 	}
+-#else
++#elif defined USE_VALGRIND
+ 	// Set access protection for block to prevent memory from deleted pool being accessed
+ 	int handle = /* //VALGRIND_MAKE_NOACCESS */ VALGRIND_MAKE_MEM_DEFINED(block, size);
+ 
+--- src/common/classes/alloc.h
++++ src/common/classes/alloc.h
+@@ -295,40 +295,60 @@
+ 
+ // operators new and delete
+ 
++#if !defined USE_ASAN
+ inline void* operator new(size_t s ALLOC_PARAMS) throw (OOM_EXCEPTION)
+ {
+ 	return MemoryPool::globalAlloc(s ALLOC_PASS_ARGS);
+ }
+ inline void* operator new[](size_t s ALLOC_PARAMS) throw (OOM_EXCEPTION)
+ {
+ 	return MemoryPool::globalAlloc(s ALLOC_PASS_ARGS);
+ }
++#endif
+ 
+ inline void* operator new(size_t s, Firebird::MemoryPool& pool ALLOC_PARAMS) throw (OOM_EXCEPTION)
+ {
++#if defined USE_ASAN
++	return operator new(s);
++#else
+ 	return pool.allocate(s ALLOC_PASS_ARGS);
++#endif
+ }
+ inline void* operator new[](size_t s, Firebird::MemoryPool& pool ALLOC_PARAMS) throw (OOM_EXCEPTION)
+ {
++#if defined USE_ASAN
++	return operator new[](s);
++#else
+ 	return pool.allocate(s ALLOC_PASS_ARGS);
++#endif
+ }
+ 
++#if !defined USE_ASAN
+ inline void operator delete(void* mem ALLOC_PARAMS) throw()
+ {
+ 	MemoryPool::globalFree(mem);
+ }
+ inline void operator delete[](void* mem ALLOC_PARAMS) throw()
+ {
+ 	MemoryPool::globalFree(mem);
+ }
++#endif
+ 
+ inline void operator delete(void* mem, Firebird::MemoryPool& pool ALLOC_PARAMS) throw()
+ {
++#if defined USE_ASAN
++	return operator delete(mem);
++#else
+ 	MemoryPool::globalFree(mem);
++#endif
+ }
+ inline void operator delete[](void* mem, Firebird::MemoryPool& pool ALLOC_PARAMS) throw()
+ {
++#if defined USE_ASAN
++	return operator delete[](mem);
++#else
+ 	MemoryPool::globalFree(mem);
++#endif
+ }
+ 
+ #ifdef DEBUG_GDS_ALLOC
+--- src/include/firebird.h
++++ src/include/firebird.h
+@@ -38,8 +38,17 @@
+ #include "gen/autoconfig.h"
+ #endif
+ 
++#if defined __clang__ && defined __has_feature
++#if __has_feature(address_sanitizer)
++#define USE_ASAN
++#endif
++#endif
++#if defined __clang__ && (defined __apple_build_version__ ? __clang_major__ >= 9 : __clang_major__ >= 4)
++#define USE_ASAN
++#endif
++
+ // Using our debugging code is pointless when we may use Valgrind features
+-#if defined(DEV_BUILD) && !defined(USE_VALGRIND)
++#if defined(DEV_BUILD) && !(defined(USE_VALGRIND) || defined(USE_ASAN))
+ #define DEBUG_GDS_ALLOC
+ #endif
+ 


More information about the Libreoffice-commits mailing list