office-gobmx/external/firebird/ubsan.patch
Stephan Bergmann 7bd520428b external/firebird: Avoid -fsanitize=nonnull-attribute
...that hits at least during the build of firebird with also ASan enabled
(support for which will be committed shortly):

> [...]/workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql -q -i [...]/workdir/UnpackedTarball/firebird/src/dbs/metadata.sql
> workdir/UnpackedTarball/firebird/src/jrd/btr.cpp:5394:19: runtime error: null pointer passed as argument 2, which is declared to never be null
> /usr/include/string.h:43:28: note: nonnull attribute specified here
>  #0 in insert_node(Jrd::thread_db*, Jrd::win*, Jrd::index_insertion*, Jrd::temporary_key*, RecordNumber*, unsigned int*, unsigned int*) at workdir/UnpackedTarball/firebird/src/jrd/btr.cpp:5394:2 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x1ae2914)
>  #1 in add_node(Jrd::thread_db*, Jrd::win*, Jrd::index_insertion*, Jrd::temporary_key*, RecordNumber*, unsigned int*, unsigned int*) at workdir/UnpackedTarball/firebird/src/jrd/btr.cpp:2279:24 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x1ac5a92)
>  #2 in BTR_insert(Jrd::thread_db*, Jrd::win*, Jrd::index_insertion*) at workdir/UnpackedTarball/firebird/src/jrd/btr.cpp:1008:21 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x1ac29b5)
>  #3 in insert_key(Jrd::thread_db*, Jrd::jrd_rel*, Jrd::Record*, Jrd::jrd_tra*, Jrd::win*, Jrd::index_insertion*, Jrd::IndexErrorContext&) at workdir/UnpackedTarball/firebird/src/jrd/idx.cpp:1475:2 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x1c62e01)
>  #4 in IDX_store(Jrd::thread_db*, Jrd::record_param*, Jrd::jrd_tra*) at workdir/UnpackedTarball/firebird/src/jrd/idx.cpp:1018:22 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x1c661a2)
>  #5 in Jrd::StoreNode::store(Jrd::thread_db*, Jrd::jrd_req*, Jrd::StmtNode::WhichTrigger) const at workdir/UnpackedTarball/firebird/src/dsql/StmtNodes.cpp:7005:5 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x21c0c96)
>  #6 in Jrd::StoreNode::execute(Jrd::thread_db*, Jrd::jrd_req*, Jrd::StmtNode::ExeState*) const at workdir/UnpackedTarball/firebird/src/dsql/StmtNodes.cpp:6942:13 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x21bf955)
>  #7 in EXE_looper(Jrd::thread_db*, Jrd::jrd_req*, Jrd::StmtNode const*) at workdir/UnpackedTarball/firebird/src/jrd/exe.cpp:1292:17 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x157f798)
>  #8 in looper_seh(Jrd::thread_db*, Jrd::jrd_req*, Jrd::StmtNode const*) at workdir/UnpackedTarball/firebird/src/jrd/exe.cpp:1426:2 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x15834fc)
>  #9 in execute_looper(Jrd::thread_db*, Jrd::jrd_req*, Jrd::jrd_tra*, Jrd::StmtNode const*, Jrd::jrd_req::req_s) at workdir/UnpackedTarball/firebird/src/jrd/exe.cpp:1023:2 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x15740c3)
>  #10 in EXE_send(Jrd::thread_db*, Jrd::jrd_req*, unsigned short, unsigned int, unsigned char const*) at workdir/UnpackedTarball/firebird/src/jrd/exe.cpp:833:2 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x1579392)
>  #11 in add_index_set(Jrd::thread_db*) at workdir/UnpackedTarball/firebird/temp/Debug/jrd/ini.cpp:2251:3 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x1efb0c2)
>  #12 in INI_format(char const*, char const*) at workdir/UnpackedTarball/firebird/temp/Debug/jrd/ini.cpp:1563:2 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x1eef3bd)
>  #13 in Jrd::JProvider::createDatabase(Firebird::CheckStatusWrapper*, char const*, unsigned int, unsigned char const*) at workdir/UnpackedTarball/firebird/src/jrd/jrd.cpp:2691:4 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x1864267)
>  #14 in Firebird::IProviderBaseImpl<Jrd::JProvider, Firebird::CheckStatusWrapper, Firebird::IPluginBaseImpl<Jrd::JProvider, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IReferenceCountedImpl<Jrd::JProvider, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IVersionedImpl<Jrd::JProvider, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IProvider> > > > > > >::cloopcreateDatabaseDispatcher(Firebird::IProvider*, Firebird::IStatus*, char const*, unsigned int, unsigned char const*) at workdir/UnpackedTarball/firebird/src/include/firebird/IdlFbInterfaces.h:9010:44 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/plugins/libEngine12.so +0x16eefb6)
>  #15 in Firebird::IAttachment* Firebird::IProvider::createDatabase<Firebird::CheckStatusWrapper>(Firebird::CheckStatusWrapper*, char const*, unsigned int, unsigned char const*) at workdir/UnpackedTarball/firebird/src/include/firebird/IdlFbInterfaces.h:2034:23 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/lib/libfbclient.so.2 +0x49cc5d)
>  #16 in Why::Dispatcher::attachOrCreateDatabase(Firebird::CheckStatusWrapper*, bool, char const*, unsigned int, unsigned char const*) at workdir/UnpackedTarball/firebird/src/yvalve/why.cpp:5681:15 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/lib/libfbclient.so.2 +0x44d0ad)
>  #17 in Why::Dispatcher::createDatabase(Firebird::CheckStatusWrapper*, char const*, unsigned int, unsigned char const*) at workdir/UnpackedTarball/firebird/src/yvalve/why.cpp:5606:9 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/lib/libfbclient.so.2 +0x44e4d4)
>  #18 in PREPARSE_execute(Firebird::CheckStatusWrapper*, Why::YAttachment**, unsigned short, char const*, bool*, unsigned short) at workdir/UnpackedTarball/firebird/src/yvalve/preparse.cpp:288:26 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/lib/libfbclient.so.2 +0x56e738)
>  #19 in Why::UtilInterface::executeCreateDatabase(Firebird::CheckStatusWrapper*, unsigned int, char const*, unsigned int, unsigned char*) at workdir/UnpackedTarball/firebird/src/yvalve/utl.cpp:587:8 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/lib/libfbclient.so.2 +0x5ee78f)
>  #20 in Firebird::IUtilBaseImpl<Why::UtilInterface, Firebird::CheckStatusWrapper, Firebird::IVersionedImpl<Why::UtilInterface, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IUtil> > >::cloopexecuteCreateDatabaseDispatcher(Firebird::IUtil*, Firebird::IStatus*, unsigned int, char const*, unsigned int, unsigned char*) at workdir/UnpackedTarball/firebird/src/include/firebird/IdlFbInterfaces.h:12375:44 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/lib/libfbclient.so.2 +0x60ed0b)
>  #21 in Firebird::IAttachment* Firebird::IUtil::executeCreateDatabase<Firebird::CheckStatusWrapper>(Firebird::CheckStatusWrapper*, unsigned int, char const*, unsigned int, unsigned char*) at workdir/UnpackedTarball/firebird/src/include/firebird/IdlFbInterfaces.h:3504:23 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql +0x603d95)
>  #22 in create_db(char const*, char*) at workdir/UnpackedTarball/firebird/temp/Debug/isql/isql.cpp:5314:38 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql +0x5aee53)
>  #23 in frontend(char const*) at workdir/UnpackedTarball/firebird/temp/Debug/isql/isql.cpp:6152:10 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql +0x59b585)
>  #24 in get_statement(char*, unsigned long, char const*) at workdir/UnpackedTarball/firebird/temp/Debug/isql/isql.cpp:7019:9 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql +0x596084)
>  #25 in do_isql() at workdir/UnpackedTarball/firebird/temp/Debug/isql/isql.cpp:5481:9 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql +0x57ba26)
>  #26 in ISQL_main(int, char**) at workdir/UnpackedTarball/firebird/temp/Debug/isql/isql.cpp:1693:3 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql +0x575ecc)
>  #27 in main at workdir/UnpackedTarball/firebird/temp/Debug/isql/isql.cpp:1599:9 (workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql +0x575149)
>  #28 in __libc_start_main at /usr/src/debug/glibc-2.26-146-gd300041c53/csu/../csu/libc-start.c:308 (/lib64/libc.so.6 +0x20f29)
>  #29 in _start at <null> (workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql +0x423219)

Change-Id: Iebff0484a792b711769f46c4823f806e9f9b2935
Reviewed-on: https://gerrit.libreoffice.org/52704
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-04-11 11:40:34 +02:00

287 lines
9 KiB
Diff

--- configure
+++ configure
@@ -21349,7 +21349,7 @@
char a;
long long b;
};
- exit((int)&((struct s*)0)->b);
+ exit((int)&((struct s*)1024)->b - 1024);
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
@@ -21384,7 +21384,7 @@
char a;
double b;
};
- exit((int)&((struct s*)0)->b);
+ exit((int)&((struct s*)1024)->b - 1024);
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
--- src/common/classes/array.h
+++ src/common/classes/array.h
@@ -149,7 +149,7 @@
void copyFrom(const Array<T, Storage>& source)
{
ensureCapacity(source.count, false);
- memcpy(data, source.data, sizeof(T) * source.count);
+ if (source.count != 0) memcpy(data, source.data, sizeof(T) * source.count);
count = source.count;
}
@@ -227,7 +227,7 @@
fb_assert(count <= FB_MAX_SIZEOF - itemsCount);
ensureCapacity(count + itemsCount);
memmove(data + index + itemsCount, data + index, sizeof(T) * (count - index));
- memcpy(data + index, items, sizeof(T) * itemsCount);
+ if (itemsCount != 0) memcpy(data + index, items, sizeof(T) * itemsCount);
count += itemsCount;
}
@@ -242,7 +242,7 @@
{
fb_assert(count <= FB_MAX_SIZEOF - itemsCount);
ensureCapacity(count + itemsCount);
- memcpy(data + count, items, sizeof(T) * itemsCount);
+ if (itemsCount != 0) memcpy(data + count, items, sizeof(T) * itemsCount);
count += itemsCount;
}
@@ -294,7 +294,7 @@
{
fb_assert(newCount >= count);
ensureCapacity(newCount);
- memset(data + count, 0, sizeof(T) * (newCount - count));
+ if (newCount != count) memset(data + count, 0, sizeof(T) * (newCount - count));
count = newCount;
}
@@ -328,7 +328,7 @@
{
fb_assert(count <= FB_MAX_SIZEOF - L.count);
ensureCapacity(count + L.count);
- memcpy(data + count, L.data, sizeof(T) * L.count);
+ if (L.count != 0) memcpy(data + count, L.data, sizeof(T) * L.count);
count += L.count;
}
@@ -462,7 +462,7 @@
T* newdata = static_cast<T*>
(this->getPool().allocate(sizeof(T) * newcapacity ALLOC_ARGS));
- if (preserve)
+ if (preserve && count != 0)
memcpy(newdata, data, sizeof(T) * count);
freeData();
data = newdata;
--- src/common/classes/fb_string.h
+++ src/common/classes/fb_string.h
@@ -674,7 +674,8 @@
}
StringType& assign(const void* s, size_type n)
{
- memcpy(baseAssign(n), s, n);
+ auto const p = baseAssign(n);
+ if (n != 0) memcpy(p, s, n);
return *this;
}
StringType& assign(const_pointer s)
--- src/common/unicode_util.cpp
+++ src/common/unicode_util.cpp
@@ -187,7 +187,7 @@
Mutex ciAiTransCacheMutex;
Array<UTransliterator*> ciAiTransCache;
- void (U_EXPORT2 *uVersionToString)(UVersionInfo versionArray, char* versionString);
+ void (U_EXPORT2 *uVersionToString)(UVersionInfo const versionArray, char* versionString);
int32_t (U_EXPORT2 *ulocCountAvailable)();
const char* (U_EXPORT2 *ulocGetAvailable)(int32_t n);
--- src/dsql/StmtNodes.cpp
+++ src/dsql/StmtNodes.cpp
@@ -6643,7 +6643,7 @@
void StoreNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
- const dsql_msg* message = dsqlGenDmlHeader(dsqlScratch, dsqlRse->as<RseNode>());
+ const dsql_msg* message = dsqlGenDmlHeader(dsqlScratch, dsqlRse == nullptr ? nullptr : dsqlRse->as<RseNode>());
dsqlScratch->appendUChar(statement2 ? blr_store2 : blr_store);
GEN_expr(dsqlScratch, dsqlRelation);
--- src/gpre/hsh.cpp
+++ src/gpre/hsh.cpp
@@ -232,7 +232,7 @@
{
SCHAR c;
- SLONG value = 0;
+ ULONG value = 0;
while (c = *string++)
value = (value << 1) + UPPER(c);
--- src/jrd/GlobalRWLock.cpp
+++ src/jrd/GlobalRWLock.cpp
@@ -78,7 +78,7 @@
cachedLock = FB_NEW_RPT(getPool(), lockLen)
Lock(tdbb, lockLen, lckType, this, lockCaching ? blocking_ast_cached_lock : NULL);
- memcpy(&cachedLock->lck_key, lockStr, lockLen);
+ if (lockLen != 0) memcpy(&cachedLock->lck_key, lockStr, lockLen);
}
GlobalRWLock::~GlobalRWLock()
--- src/jrd/Optimizer.cpp
+++ src/jrd/Optimizer.cpp
@@ -368,7 +368,7 @@
// Allocate needed indexScratches
- index_desc* idx = csb_tail->csb_idx->items;
+ index_desc* idx = csb_tail->csb_idx == nullptr ? nullptr : csb_tail->csb_idx->items;
for (int i = 0; i < csb_tail->csb_indices; ++i, ++idx)
indexScratches.add(IndexScratch(p, tdbb, idx, csb_tail));
}
--- src/jrd/blb.cpp
+++ src/jrd/blb.cpp
@@ -1786,7 +1786,7 @@
arg.slice_base = array->arr_data;
SLONG variables[64];
- memcpy(variables, param, MIN(sizeof(variables), param_length));
+ if (param_length != 0) memcpy(variables, param, MIN(sizeof(variables), param_length));
if (SDL_walk(tdbb->tdbb_status_vector, sdl, array->arr_data, &array_desc->arr_desc,
variables, slice_callback, &arg))
--- src/jrd/btn.cpp
+++ src/jrd/btn.cpp
@@ -387,7 +387,7 @@
put_short(pagePointer, offset);
pagePointer += sizeof(USHORT);
- memmove(pagePointer, data, length);
+ if (length != 0) memmove(pagePointer, data, length);
pagePointer += length;
return pagePointer;
}
@@ -622,7 +622,7 @@
}
// Store data
- if (withData) {
+ if (withData && length != 0) {
memcpy(pagePointer, data, length);
}
pagePointer += length;
--- src/jrd/btr.cpp
+++ src/jrd/btr.cpp
@@ -5206,7 +5206,7 @@
// Push node on end in list
jumpNodes->add(jumpNode);
// Store new data in jumpKey, so a new jump node can calculate prefix
- memcpy(jumpData + jumpNode.prefix, jumpNode.data, jumpNode.length);
+ if (jumpNode.length != 0) memcpy(jumpData + jumpNode.prefix, jumpNode.data, jumpNode.length);
jumpLength = jumpNode.length + jumpNode.prefix;
// Check if this could be our split point (if we need to split)
@@ -5391,7 +5391,7 @@
// First, store needed data for beforeInsertNode into tempData.
HalfStaticArray<UCHAR, MAX_KEY> tempBuf;
UCHAR* tempData = tempBuf.getBuffer(newLength);
- memcpy(tempData, beforeInsertNode.data + newPrefix - beforeInsertNode.prefix, newLength);
+ if (newLength != 0) memcpy(tempData, beforeInsertNode.data + newPrefix - beforeInsertNode.prefix, newLength);
beforeInsertNode.prefix = newPrefix;
beforeInsertNode.length = newLength;
@@ -5611,7 +5611,7 @@
for (size_t i = 0; i < jumpNodes->getCount(); i++, index++)
{
UCHAR* q = new_key->key_data + walkJumpNode[i].prefix;
- memcpy(q, walkJumpNode[i].data, walkJumpNode[i].length);
+ if (walkJumpNode[i].length != 0) memcpy(q, walkJumpNode[i].data, walkJumpNode[i].length);
if (index == splitJumpNodeIndex)
{
jn = &walkJumpNode[i];
@@ -5636,7 +5636,7 @@
const USHORT length = walkJumpNode[i].prefix + walkJumpNode[i].length;
UCHAR* newData = FB_NEW_POOL(*tdbb->getDefaultPool()) UCHAR[length];
memcpy(newData, new_key->key_data, walkJumpNode[i].prefix);
- memcpy(newData + walkJumpNode[i].prefix, walkJumpNode[i].data,
+ if (walkJumpNode[i].length != 0) memcpy(newData + walkJumpNode[i].prefix, walkJumpNode[i].data,
walkJumpNode[i].length);
delete[] walkJumpNode[i].data;
walkJumpNode[i].prefix = 0;
--- src/jrd/evl.cpp
+++ src/jrd/evl.cpp
@@ -415,7 +415,7 @@
case dtype_real:
case dtype_sql_time:
case dtype_sql_date:
- value->vlu_misc.vlu_long = *((SLONG*) from.dsc_address);
+ memcpy(&value->vlu_misc.vlu_long, from.dsc_address, sizeof (SLONG));
return;
case dtype_int64:
--- src/jrd/lck.cpp
+++ src/jrd/lck.cpp
@@ -488,7 +488,7 @@
break;
}
- dbb->dbb_lock_mgr->shutdownOwner(tdbb, owner_handle_ptr);
+ LockManager::shutdownOwner(dbb->dbb_lock_mgr, tdbb, owner_handle_ptr);
}
--- src/lock/lock.cpp
+++ src/lock/lock.cpp
@@ -441,7 +441,7 @@
}
-void LockManager::shutdownOwner(thread_db* tdbb, SRQ_PTR* owner_handle)
+void LockManager::shutdownOwner(LockManager* This, thread_db* tdbb, SRQ_PTR* owner_handle)
{
/**************************************
*
@@ -460,8 +460,9 @@
if (!owner_offset)
return;
- LockTableGuard guard(this, FB_FUNCTION, owner_offset);
+ LockTableGuard guard(This, FB_FUNCTION, owner_offset);
+#define SRQ_BASE ((UCHAR*) This->m_sharedMemory->getHeader())
own* owner = (own*) SRQ_ABS_PTR(owner_offset);
if (!owner->own_count)
return;
@@ -472,7 +473,7 @@
while (owner->own_ast_count)
{
{ // checkout scope
- LockTableCheckout checkout(this, FB_FUNCTION);
+ LockTableCheckout checkout(This, FB_FUNCTION);
EngineCheckout cout(tdbb, FB_FUNCTION, true);
Thread::sleep(10);
}
@@ -484,8 +485,9 @@
// released before destroying the lock owner. This is not strictly required,
// but it enforces the proper object lifetime discipline through the codebase.
fb_assert(SRQ_EMPTY(owner->own_requests));
+#define SRQ_BASE ((UCHAR*) m_sharedMemory->getHeader())
- purge_owner(owner_offset, owner);
+ This->purge_owner(owner_offset, owner);
*owner_handle = 0;
}
--- src/lock/lock_proto.h
+++ src/lock/lock_proto.h
@@ -402,7 +402,7 @@
static void destroy(LockManager*);
bool initializeOwner(Firebird::CheckStatusWrapper*, LOCK_OWNER_T, UCHAR, SRQ_PTR*);
- void shutdownOwner(thread_db*, SRQ_PTR*);
+ static void shutdownOwner(LockManager* This, thread_db*, SRQ_PTR*);
SRQ_PTR enqueue(thread_db*, Firebird::CheckStatusWrapper*, SRQ_PTR, const USHORT,
const UCHAR*, const USHORT, UCHAR, lock_ast_t, void*, SINT64, SSHORT, SRQ_PTR);