Bug 1200075 - Do not avoid sqlite3 using _msize. r=froydnj

It was setup this way in bug 719579 for legitimate reasons (because
_msize would end up using the system symbol, which would crash trying to
get the size information from jemalloc allocations), but these reasons
don't apply anymore: back then the linking situation was different, and
nowadays, mozglue.dll exports its own _msize which plugs into
mozjemalloc, and sqlite is folded into nss3.dll, which links against
mozglue.dll, such that using _msize on mozjemalloc allocations works.

For some reason, while _msize (and other similar functions) are exported
from mozglue.dll without an explicit instruction to do so on clang-cl
builds, that's not the case for mingw builds (presumably related to the
definition of these functions in system headers, or lack thereof). So
we also add MOZ_EXPORT for them.

Differential Revision: https://phabricator.services.mozilla.com/D81286
This commit is contained in:
Mike Hommey 2020-06-29 16:22:50 +00:00
parent a39f7c1e96
commit eb6d411650
2 changed files with 9 additions and 8 deletions

View File

@ -4851,7 +4851,7 @@ MOZ_EXPORT void* (*__memalign_hook)(size_t, size_t) = memalign_impl;
#endif
#ifdef XP_WIN
void* _recalloc(void* aPtr, size_t aCount, size_t aSize) {
MOZ_EXPORT void* _recalloc(void* aPtr, size_t aCount, size_t aSize) {
size_t oldsize = aPtr ? AllocInfo::Get(aPtr).Size() : 0;
CheckedInt<size_t> checkedSize = CheckedInt<size_t>(aCount) * aSize;
@ -4876,7 +4876,7 @@ void* _recalloc(void* aPtr, size_t aCount, size_t aSize) {
// This impl of _expand doesn't ever actually expand or shrink blocks: it
// simply replies that you may continue using a shrunk block.
void* _expand(void* aPtr, size_t newsize) {
MOZ_EXPORT void* _expand(void* aPtr, size_t newsize) {
if (AllocInfo::Get(aPtr).Size() >= newsize) {
return aPtr;
}
@ -4884,5 +4884,7 @@ void* _expand(void* aPtr, size_t newsize) {
return nullptr;
}
size_t _msize(void* aPtr) { return DefaultMalloc::malloc_usable_size(aPtr); }
MOZ_EXPORT size_t _msize(void* aPtr) {
return DefaultMalloc::malloc_usable_size(aPtr);
}
#endif

View File

@ -67,11 +67,10 @@ if CONFIG['OS_TARGET'] == 'Android':
# default to user readable only to fit Android security model
DEFINES['SQLITE_DEFAULT_FILE_PERMISSIONS'] = '0600'
# Force using malloc_usable_size when building with jemalloc because _msize
# causes assertions on Win64. See bug 719579.
if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['MOZ_MEMORY']:
DEFINES['HAVE_MALLOC_USABLE_SIZE'] = True
DEFINES['SQLITE_WITHOUT_MSIZE'] = True
# Force using _msize on mingw, as sqlite3 only enables it with MSVC.
if CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CC_TYPE'] != 'clang-cl':
DEFINES['SQLITE_USE_MALLOC_H'] = True
DEFINES['SQLITE_USE_MSIZE'] = True
# Omit unused functions to save some library footprint.
DEFINES['SQLITE_OMIT_DEPRECATED'] = True