History log of /6.6.0/platform/src/global_new_replacement.cc (Results 1 - 17 of 17)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: v7.0.2, v6.6.1, v7.0.0, v6.5.1, v6.0.3
# 4fd5c7e9 07-May-2019 Jim Walker <jim@couchbase.com>

MB-34074: Add missing global new/delete nothrow variants

Issue discovered when using the thread_local keyword on
cento7 (glibc). Found that glibc was performing a nothrow
new in the

MB-34074: Add missing global new/delete nothrow variants

Issue discovered when using the thread_local keyword on
cento7 (glibc). Found that glibc was performing a nothrow
new in the runtime intialisation of the thread_local and
later using a standard delete, this lead to an attempt
to free via jemalloc when the allocation was made by
system allocator.

Change-Id: I66570f1b1feb7614fdaa94bee44a71c881e7be79
Reviewed-on: http://review.couchbase.org/108774
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


# da567ebf 20-Mar-2019 Trond Norbye <trond.norbye@gmail.com>

Get rid of config.h

Define all flags as compiler options with -DFOO=1

Change-Id: I8deab908c9feb08a090a56dafa8c3a9ecb1ed1e3
Reviewed-on: http://review.couchbase.org/106500
Te

Get rid of config.h

Define all flags as compiler options with -DFOO=1

Change-Id: I8deab908c9feb08a090a56dafa8c3a9ecb1ed1e3
Reviewed-on: http://review.couchbase.org/106500
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>

show more ...


Revision tags: v5.5.4
# b2487b03 05-Sep-2018 James Harrison <00jamesh@gmail.com>

MB-30029: Add support for jemalloc sized deallocation

Make use of jemalloc support for sized deallocation by having
the sized delete operator call je_sdallocx if available.

Chan

MB-30029: Add support for jemalloc sized deallocation

Make use of jemalloc support for sized deallocation by having
the sized delete operator call je_sdallocx if available.

Change-Id: I8db4bc6c66fab415128ff52f8bd1b6f8e2dca80b
Reviewed-on: http://review.couchbase.org/105091
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Daniel Owen <owend@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>

show more ...


# b8551f55 09-Sep-2018 James Harrison <00jamesh@gmail.com>

MB-30029: Add basic sized delete operator

Jemalloc 5.1 defines a c++14 sized delete operator which will be used in
preference to the standard delete operator (when deleting a complete ty

MB-30029: Add basic sized delete operator

Jemalloc 5.1 defines a c++14 sized delete operator which will be used in
preference to the standard delete operator (when deleting a complete type).
We must interpose our own to ensure we call the delete hook and can track
deallocations properly.

The operator defined in this patch just calls the delete hook and free,
ignoring the size parameter.

Array forms of the new and delete operator have been overloaded in version
5.1. This requires us to overload our version to call cb_malloc and
cb_free appropriately.

For some reason, under TSan, adding the sized delete operator changes
the runtime linking order which causes RocksDB to start calling our
overload of malloc_usable_size. This is fine, but there exists a bug
where any call to malloc_usable_size when using the system allocator
is infinitely recursive causing a stack overflow segfault. Fix this by
only overriding the function when we are NOT using the system allocator.

Change-Id: I7ccd49957ad9f02a6d35d2a50fa5ef1d303426b0
Reviewed-on: http://review.couchbase.org/104970
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Daniel Owen <owend@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>

show more ...


# d5890aab 13-Feb-2019 Ben Huddleston <ben.huddleston@couchbase.com>

Revert "MB-30029: Add basic sized delete operator"

This reverts commit f5f6a069c8fa0abfd0e0939d16593f28498337d1.

Change-Id: I319769ae16053d067a56744450e24e180b39ab09
Reviewed-on

Revert "MB-30029: Add basic sized delete operator"

This reverts commit f5f6a069c8fa0abfd0e0939d16593f28498337d1.

Change-Id: I319769ae16053d067a56744450e24e180b39ab09
Reviewed-on: http://review.couchbase.org/104890
Reviewed-by: Ben Huddleston <ben.huddleston@couchbase.com>
Tested-by: Ben Huddleston <ben.huddleston@couchbase.com>

show more ...


# b30d5004 13-Feb-2019 Ben Huddleston <ben.huddleston@couchbase.com>

Revert "MB-30029: Add support for jemalloc sized deallocation"

This reverts commit e11be8160817150aa9fded367f7f63bf939fa6d4.

Change-Id: I2aa38cf056ccab624da85481389d4a541cb21f8c

Revert "MB-30029: Add support for jemalloc sized deallocation"

This reverts commit e11be8160817150aa9fded367f7f63bf939fa6d4.

Change-Id: I2aa38cf056ccab624da85481389d4a541cb21f8c
Reviewed-on: http://review.couchbase.org/104889
Reviewed-by: Ben Huddleston <ben.huddleston@couchbase.com>
Tested-by: Ben Huddleston <ben.huddleston@couchbase.com>

show more ...


# e11be816 05-Sep-2018 James Harrison <00jamesh@gmail.com>

MB-30029: Add support for jemalloc sized deallocation

Make use of jemalloc support for sized deallocation by having
the sized delete operator call je_sdallocx if available.

Chan

MB-30029: Add support for jemalloc sized deallocation

Make use of jemalloc support for sized deallocation by having
the sized delete operator call je_sdallocx if available.

Change-Id: Ic2011e7d66a5fa642925b5ef8589113f0ca7df28
Reviewed-on: http://review.couchbase.org/99241
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


# f5f6a069 09-Sep-2018 James Harrison <00jamesh@gmail.com>

MB-30029: Add basic sized delete operator

Jemalloc 5.1 defines a c++14 sized delete operator which will be used in
preference to the standard delete operator (when deleting a complete ty

MB-30029: Add basic sized delete operator

Jemalloc 5.1 defines a c++14 sized delete operator which will be used in
preference to the standard delete operator (when deleting a complete type).
We must interpose our own to ensure we call the delete hook and can track
deallocations properly.

The operator defined in this patch just calls the delete hook and free,
ignoring the size parameter.

Array forms of the new and delete operator have been overloaded in version
5.1. This requires us to overload our version to call cb_malloc and
cb_free appropriately.

For some reason, under TSan, adding the sized delete operator changes
the runtime linking order which causes RocksDB to start calling our
overload of malloc_usable_size. This is fine, but there exists a bug
where any call to malloc_usable_size when using the system allocator
is infinitely recursive causing a stack overflow segfault. Fix this by
only overriding the function when we are NOT using the system allocator.

Change-Id: Iab8cfc36fbefc7f0216ec130426dd6d6cbfe3ddd
Reviewed-on: http://review.couchbase.org/99992
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>

show more ...


Revision tags: v5.5.0, v4.6.5
# 5c66a57a 25-Aug-2017 James Harrison <00jamesh@gmail.com>

RocksDB: Make interposed malloc_usable_size usable by RocksDB

Without PLATFORM_PUBLIC_API, the symbol wasn't exported, and would not
be used by RocksDB.
Annoyingly, the direct test o

RocksDB: Make interposed malloc_usable_size usable by RocksDB

Without PLATFORM_PUBLIC_API, the symbol wasn't exported, and would not
be used by RocksDB.
Annoyingly, the direct test of malloc_usable_size passed because it is
statically linked against the platform target, which includes
global_new_replacement.cc.
In contrast, RocksDB is a shared library, and all other tests which made
use of it would segfault (as would memcached when running normally) as
RocksDB would call the system malloc_usable_size with memory allocated
by JEMalloc.

Change-Id: I11d7cb3cb46ff018fb7b51f84249889bf3ce9a22
Reviewed-on: http://review.couchbase.org/82764
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Manu Dhundi <manu@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>

show more ...


Revision tags: v5.0.0
# a06044f3 07-Aug-2017 James Harrison <00jamesh@gmail.com>

Add cb_malloc_usable_size and interpose malloc_usable_size

As we have a global new replacement, libraries could end up calling the
system malloc_usable_size (if present) with a pointer t

Add cb_malloc_usable_size and interpose malloc_usable_size

As we have a global new replacement, libraries could end up calling the
system malloc_usable_size (if present) with a pointer to memory
allocated by JEMalloc.

This was first noted when testing with RocksDB, but would safeguard
against it cropping up elsewhere.

Change-Id: Ifd2beae94381c6ec86edf65e93469e67ccbdda7c
Reviewed-on: http://review.couchbase.org/82043
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>

show more ...


Revision tags: v4.6.0, v4.6.0-DP
# f85e2843 04-Oct-2016 Trond Norbye <trond.norbye@gmail.com>

Don't use #pragma GCC on win32

Change-Id: I8996e2915a232ac2ae6057a553c6f4b66377b8d3
Reviewed-on: http://review.couchbase.org/68310
Tested-by: buildbot <build@couchbase.com>
Revie

Don't use #pragma GCC on win32

Change-Id: I8996e2915a232ac2ae6057a553c6f4b66377b8d3
Reviewed-on: http://review.couchbase.org/68310
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>

show more ...


# ab7b9c11 28-Sep-2016 Dave Rigby <daver@couchbase.com>

MB-20769: Remove WEAK symbol attributes from operator new/delete

These were only added temporarily to aid in migration to the new
cbmalloc API, and can now be removed.

Change-Id

MB-20769: Remove WEAK symbol attributes from operator new/delete

These were only added temporarily to aid in migration to the new
cbmalloc API, and can now be removed.

Change-Id: Ie9426fc3f0cdaf7c8414f40e1890dbcb27bb61cf
Reviewed-on: http://review.couchbase.org/68102
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Daniel Owen <owend@couchbase.com>

show more ...


# 3033f677 31-Aug-2016 Dave Rigby <daver@couchbase.com>

MB-20769: Use cbmalloc for C++ new/delete allocations

(Re-apply after previous revert, due to being merged before other
dependant patches in projects' were merged).

Add a new s

MB-20769: Use cbmalloc for C++ new/delete allocations

(Re-apply after previous revert, due to being merged before other
dependant patches in projects' were merged).

Add a new source file (global_new_replacement.cc) which is included
into platform and will use cb_malloc/cb_free for all C++-style memory
allocations (those via new/delete).

Given that all binaries which link platform will be using cbmalloc for
any allocations made /by/ platform, we need to ensure that mismatches
between memory allocators (i.e. allocating with cb_malloc() but
freeing using free() do not occur.

This is particulary problematic on Windows, as there each binary (exe,
dll, etc) can have its *own* version of `operator new`. Therefore a
program which doesn't itself link global_new_replacment.cc and calls
`new` will get memory from libc malloc, but if it calls a platform
function which allocates memory (e.g. a one returning std::string)
that will be allocated via cb_malloc(). This quickly becomes a problem
(typically resulting in a crash) when the program tries to delete the
string (or even resize it) - as the program will try to use libc and
crash.

To solve this problem we re-define the `platform` library. Instead of
it being a shared library, we define it as a _static_ library
consisting of:

* one source file - global_new_replacement.cc
* one target_link_library - the 'original' platforn shared library,
now renamed to platform_so.

The effect of this is that all targets which previously linked
platform will additionally (statically) link
global_new_replacement.cc, ensuring they will use cbmalloc for any C++
memory allocations.

Note: both operator new & delete are marked as weak symbols to
simplify migrating existing code. For example ep-engine has test
code which defines its own operator new/delete, and if we don't
define these symbols as weak we'll get a linker error when this
patch is merged.

Once the other components have been updated to no longer link
operator new/delete twice, this attribute can be removed.

Change-Id: I0954c23994b19002d75db5cc2f987722edfc2c7c
Reviewed-on: http://review.couchbase.org/67818
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>

show more ...


# 8616395e 20-Sep-2016 Dave Rigby <daver@couchbase.com>

Revert "Merge remote-tracking branch 'couchbase/watson'"

This reverts commit 21cd2c5f687a378a25cfadbb0fff95036287d90e, reversing
changes made to 21991f2650ce31e787d6666268ef6a15b0bc4cfb.

Revert "Merge remote-tracking branch 'couchbase/watson'"

This reverts commit 21cd2c5f687a378a25cfadbb0fff95036287d90e, reversing
changes made to 21991f2650ce31e787d6666268ef6a15b0bc4cfb.

The merge needs to be split into two chunks - the first which fixes
the existing incorrect uses of malloc/free etc (and then other
components can also have their fixes merged), the second chunk to
actually start using cb_malloc.

Reverting back to pre-merge, so it can be split.

Change-Id: I29da333981733513275c40d5114552a98179db91
Reviewed-on: http://review.couchbase.org/67810
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>

show more ...


# cdd8270b 31-Aug-2016 Dave Rigby <daver@couchbase.com>

MB-20769: Use cbmalloc for C++ new/delete allocations

(Re-apply after previous revert, due to being merged before other
dependant patches in projects' were merged).

Add a new s

MB-20769: Use cbmalloc for C++ new/delete allocations

(Re-apply after previous revert, due to being merged before other
dependant patches in projects' were merged).

Add a new source file (global_new_replacement.cc) which is included
into platform and will use cb_malloc/cb_free for all C++-style memory
allocations (those via new/delete).

Given that all binaries which link platform will be using cbmalloc for
any allocations made /by/ platform, we need to ensure that mismatches
between memory allocators (i.e. allocating with cb_malloc() but
freeing using free() do not occur.

This is particulary problematic on Windows, as there each binary (exe,
dll, etc) can have its *own* version of `operator new`. Therefore a
program which doesn't itself link global_new_replacment.cc and calls
`new` will get memory from libc malloc, but if it calls a platform
function which allocates memory (e.g. a one returning std::string)
that will be allocated via cb_malloc(). This quickly becomes a problem
(typically resulting in a crash) when the program tries to delete the
string (or even resize it) - as the program will try to use libc and
crash.

To solve this problem we re-define the `platform` library. Instead of
it being a shared library, we define it as a _static_ library
consisting of:

* one source file - global_new_replacement.cc
* one target_link_library - the 'original' platforn shared library,
now renamed to platform_so.

The effect of this is that all targets which previously linked
platform will additionally (statically) link
global_new_replacement.cc, ensuring they will use cbmalloc for any C++
memory allocations.

Note: both operator new & delete are marked as weak symbols to
simplify migrating existing code. For example ep-engine has test
code which defines its own operator new/delete, and if we don't
define these symbols as weak we'll get a linker error when this
patch is merged.

Once the other components have been updated to no longer link
operator new/delete twice, this attribute can be removed.

Change-Id: I0954c23994b19002d75db5cc2f987722edfc2c7c
Reviewed-on: http://review.couchbase.org/67539
Well-Formed: buildbot <build@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Daniel Owen <owend@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>

show more ...


# 8a667e52 08-Sep-2016 Dave Rigby <daver@couchbase.com>

Revert "MB-20769: Use cbmalloc for C++ new/delete allocations"

This patch needs further changes to be committed to memcached before
merging (memory tracking is currently broken with this

Revert "MB-20769: Use cbmalloc for C++ new/delete allocations"

This patch needs further changes to be committed to memcached before
merging (memory tracking is currently broken with this in). Backing
out until those are ready.

This reverts commit dd5bc49594cb3fcdd587e3a8b4140059e617267b.

Change-Id: I178337a86f7eccc4e07796098fbd875e970631b3
Reviewed-on: http://review.couchbase.org/67522
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Dave Rigby <daver@couchbase.com>

show more ...


# dd5bc495 31-Aug-2016 Dave Rigby <daver@couchbase.com>

MB-20769: Use cbmalloc for C++ new/delete allocations

Add a new source file (global_new_replacement.cc) which
is included into platform and will use cb_malloc/cb_free for all C++-style

MB-20769: Use cbmalloc for C++ new/delete allocations

Add a new source file (global_new_replacement.cc) which
is included into platform and will use cb_malloc/cb_free for all C++-style
memory allocations (those via new/delete).

Given that all binaries which link platform will be using cbmalloc for any
allocations made /by/ platform, we need to ensure that mismatches between
memory allocators (i.e. allocating with cb_malloc() but freeing using
free() do not occur.

This is particulary problematic on Windows, as there each binary (exe,
dll, etc) can have its *own* version of `operator new`. Therefore a
program which doesn't itself link global_new_replacment.cc and calls `new`
will get memory from libc malloc, but if it calls a platform function
which allocates memory (e.g. a one returning std::string) that will be
allocated via cb_malloc(). This quickly becomes a problem (typically
resulting in a crash) when the program tries to delete the string (or even
resize it) - as the program will try to use libc and crash.

To solve this problem we re-define the `platform` library. Instead of it
being a shared library, we define it as a _static_ library consisting of:

* one source file - global_new_replacement.cc
* one target_link_library - the 'original' platforn shared library, now
renamed to platform_so.

The effect of this is that all targets which previously linked platform
will additionally (statically) link global_new_replacement.cc, ensuring
they will use cbmalloc for any C++ memory allocations.

Note: both operator new & delete are marked as weak symbols to simplify
migrating existing code. For example ep-engine has test code which
defines its own operator new/delete, and if we don't define these
symbols as weak we'll get a linker error when this patch is merged.

Once the other components have been updated to no longer link
operator new/delete twice, this attribute can be removed.

Change-Id: I03d088810d8709a053e9d57bd30ebfafea51da38
Reviewed-on: http://review.couchbase.org/67301
Well-Formed: buildbot <build@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>

show more ...