History log of /4.5.1-MP3/platform/ (Results 1 - 25 of 191)
Revision (<<< Hide revision tags) (Show revision tags >>>)Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
Revision tags: v6.0.3, v5.5.4, v5.5.0, v4.6.5, v5.0.0, v4.6.0, v4.6.0-DP, v4.5.1-MP1
d74f197030-Aug-2016 Dave Rigby <daver@couchbase.com>

MB-20770: Switch memory tracking from {TC,je}malloc -> cbmalloc

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

O

MB-20770: Switch memory tracking from {TC,je}malloc -> cbmalloc

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

Only change necessary is on OS X, where we have cbmalloc and friends
call je_malloc directly (when it is selected) instead of calling
malloc().

This means that cbmalloc no longer goes from:

* cbmalloc -> call cbmalloc_hooks, call malloc()
-> darwin_zone.cc:malloc (ep_engine) -> call hooks, call je_malloc

and instead does:

* cbmalloc -> call cbmalloc_hooks, call je_malloc.

Change-Id: I7bfd2c27886eb9b4ec84eec06f7e3258db0b781a
Reviewed-on: http://review.couchbase.org/67540
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Daniel Owen <owend@couchbase.com>
Tested-by: buildbot <build@couchbase.com>

show more ...

cdd8270b31-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 ...

9ca8749409-Sep-2016 Dave Rigby <daver@couchbase.com>

MB-20586: [cbmalloc] With jemalloc, use system symbols for now

TEMP: jemalloc has no new/delete hooks itself, and we instead rely on
either our own custom zone (OS X; darwin_zone.c) or o

MB-20586: [cbmalloc] With jemalloc, use system symbols for now

TEMP: jemalloc has no new/delete hooks itself, and we instead rely on
either our own custom zone (OS X; darwin_zone.c) or our own
malloc/free symbols (alloc_hooks_jemalloc.cc) to intercept
malloc/realloc etc and call the memory hook (before chaining to the
real allocator).

This means that during the transition to cbmalloc, we still need to
call the 'normal' malloc function to ensure that the current
allocator-specific memory tracking hooks (memcached
MallocHooks::add_new_hook) are invoked.

When we subsequently flip MallocHooks::add_new_hook to instead call
cbmalloc's memory tracking cb_add_new_hook), we will change the
MALLOC_PREFIX to 'je_' and remove our own custom zone & own
malloc/free symbols.

This patch essentially lets us change the rest of KV-engine to call
cb_malloc/cb_free (instead of 'malloc/free') and have no effect on the
actual way memory tracking is done *until* we flip the MALLOC_PREFIX
to 'je_' in a subsequent patch.

Change-Id: I0ca29cf3b14bf326f413472e5330b4ac1fe9af19
Reviewed-on: http://review.couchbase.org/67543
Well-Formed: buildbot <build@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Daniel Owen <owend@couchbase.com>

show more ...

8a667e5208-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 ...

d849ccac08-Sep-2016 Dave Rigby <daver@couchbase.com>

Revert "MB-20770: Switch memory tracking from {TC,je}malloc -> cbmalloc"

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

Revert "MB-20770: Switch memory tracking from {TC,je}malloc -> cbmalloc"

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 f9c4772b89b4d3ff809b0e1d70809315924cbed2.

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

show more ...

f9c4772b30-Aug-2016 Dave Rigby <daver@couchbase.com>

MB-20770: Switch memory tracking from {TC,je}malloc -> cbmalloc

Only change necessary is on OS X, where we have cbmalloc and friends call
je_malloc directly (when it is selected) instead

MB-20770: Switch memory tracking from {TC,je}malloc -> cbmalloc

Only change necessary is on OS X, where we have cbmalloc and friends call
je_malloc directly (when it is selected) instead of calling malloc().

This means that cbmalloc no longer goes from:

* cbmalloc -> call cbmalloc_hooks, call malloc()
-> darwin_zone.cc:malloc (ep_engine) -> call hooks, call je_malloc

and instead does:

* cbmalloc -> call cbmalloc_hooks, call je_malloc.

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

show more ...

dd5bc49531-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 ...

Revision tags: v4.5.1
6d5dc98118-Aug-2016 Dave Rigby <daver@couchbase.com>

MB-20769: Use cbmalloc for the rest of platform

Update platform library to use cbmalloc instead of libc malloc for all
memory allocation.

Change-Id: I740161c705c72355c66512b4226

MB-20769: Use cbmalloc for the rest of platform

Update platform library to use cbmalloc instead of libc malloc for all
memory allocation.

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

show more ...

08792fd518-Aug-2016 Dave Rigby <daver@couchbase.com>

MB-20769: Use cbmalloc for cJSON

cJSON performs memory allocation internally, and also allocates memory
which is returned (either directly or indirectly) to clients. For both
cases i

MB-20769: Use cbmalloc for cJSON

cJSON performs memory allocation internally, and also allocates memory
which is returned (either directly or indirectly) to clients. For both
cases it uses a set of malloc functions to perform allocation, which
default to the standard system malloc/free etc.

This patch changes the default malloc functions to be cbmalloc (the
user can still use the hook API to overide to something different). It
also fixes a couple of instances where the system functions were
incorrectly hard-coded.

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

show more ...

4835251c18-Aug-2016 Dave Rigby <daver@couchbase.com>

MB-20586: Add cb_malloc memory allocation API

Add a set of our own memory allocation functions:

* cb_malloc
* cb_calloc
* cb_realloc
* cb_free

These function in

MB-20586: Add cb_malloc memory allocation API

Add a set of our own memory allocation functions:

* cb_malloc
* cb_calloc
* cb_realloc
* cb_free

These function in the same way as their standard library namesakes,
with the addition of:

1. Allows applications to register callbacks to be called on any
memory allocation / deletion (so memcached/ep-engine can track
allocations).

2. Allow us to use an alternative memory allocator instead of the
system (TCMalloc, jemalloc etc).

Also add equivalents for libc functions which allocate memory
internally. Instead we allocate via cb_malloc:

* cb_strdup

Change-Id: I45e15b2b2e3a939344322164354acbae4aba2d72
Reviewed-on: http://review.couchbase.org/67065
Well-Formed: buildbot <build@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>

show more ...

349e6e8a22-Aug-2016 Trond Norbye <trond.norbye@gmail.com>

MB-20625: Backport isFile method

Change-Id: I1bcde0d41fa089bfc8381d36a33ee60e26a4c5f6
Reviewed-on: http://review.couchbase.org/66952
Tested-by: buildbot <build@couchbase.com>
Wel

MB-20625: Backport isFile method

Change-Id: I1bcde0d41fa089bfc8381d36a33ee60e26a4c5f6
Reviewed-on: http://review.couchbase.org/66952
Tested-by: buildbot <build@couchbase.com>
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>

show more ...

9ed45ce121-Jun-2016 Trond Norbye <trond.norbye@gmail.com>

MB-19390: Use #ifdef wrapper for strings.h

Our implementation of strings.h for win32 defines types
differently than forestdb, and that didn't use to be
a problems since forestdb don'

MB-19390: Use #ifdef wrapper for strings.h

Our implementation of strings.h for win32 defines types
differently than forestdb, and that didn't use to be
a problems since forestdb don't include strings.h. BUT now
that we're trying to use jemalloc on windows _IT_ tries to
include strings.h, which would cause a conflict with the
values defined by forestdb.

By using #ifndef STRINGS_H forestdb may skip the inclusion
of strings.h (it isn't needed anyway) and we don't have
to change any of the values we've already tested both
ForestDB and Couchbase server with.

Change-Id: I39df6ec9597f45d5a69533e0d2ccb28ef57183da
Reviewed-on: http://review.couchbase.org/65086
Well-Formed: buildbot <build@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>

show more ...

b574994c24-May-2016 Dave Rigby <daver@couchbase.com>

MB-19605: Fix compile warning in checked_snprintf

checked_snprintf.cc:47:20: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]

} e

MB-19605: Fix compile warning in checked_snprintf

checked_snprintf.cc:47:20: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]

} else if (ret >= size) {
^

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

show more ...

Revision tags: v4.5.0
ae2a7a2413-May-2016 Trond Norbye <trond.norbye@gmail.com>

MB-19605: Create checked_snprintf for C++ calls to snprintf

Change-Id: I05a701a637fd87262b104a58d589f32b4819b663
Reviewed-on: http://review.couchbase.org/64026
Tested-by: buildbot <b

MB-19605: Create checked_snprintf for C++ calls to snprintf

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

show more ...

0f25d79011-May-2016 Dave Rigby <daver@couchbase.com>

MB-19580: print_backtrace_to_buffer: fix buffer size calculation

print_backtrace_to_buffer() was incorrectly checking for a negative
return value from snprintf() to indicate failure, ins

MB-19580: print_backtrace_to_buffer: fix buffer size calculation

print_backtrace_to_buffer() was incorrectly checking for a negative
return value from snprintf() to indicate failure, instead of a value
exceeding the buffer size. This meant it didn't detect when the buffer
was too small, and overran it.

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

show more ...

e264bec511-May-2016 Dave Rigby <daver@couchbase.com>

Convert backtrace_test to C++ / GTest

In preparation for test expansion.

Change-Id: Idf811584a7ed710499e380ae213bb0700c9b773f
Reviewed-on: http://review.couchbase.org/63932

Convert backtrace_test to C++ / GTest

In preparation for test expansion.

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

show more ...

c8f188cc22-Mar-2016 Trond Norbye <trond.norbye@gmail.com>

Add helper function to add boolean to cJSON

Change-Id: I00181ccfc8e28eca1e968b670a70dba5278b936b
Reviewed-on: http://review.couchbase.org/61806
Tested-by: buildbot <build@couchbase.c

Add helper function to add boolean to cJSON

Change-Id: I00181ccfc8e28eca1e968b670a70dba5278b936b
Reviewed-on: http://review.couchbase.org/61806
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>

show more ...

1988bc5514-Mar-2016 Dave Rigby <daver@couchbase.com>

Add NOEXCEPT macro for C++ noexcept keyword

The C++11 keyword is needed when defining a subclass of
std::exception, as the std::exception::what() virtual method requires
it. However

Add NOEXCEPT macro for C++ noexcept keyword

The C++11 keyword is needed when defining a subclass of
std::exception, as the std::exception::what() virtual method requires
it. However not all platforms[*] support the keyword, therefore define
a NOEXCEPT macro which expand to the correct thing depending on the
compiler

[*] Looking at you, MSVC 2013 and older...

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

show more ...

Revision tags: v4.1.0
9256bb3031-Jul-2015 Dave Rigby <daver@couchbase.com>

cb_rand/Windows: Simplify CryptAcquireContext usage

We don't actually need a 'full' cryptographic service provider (CSP),
only a 'verify' context to generate random bytes.

Chang

cb_rand/Windows: Simplify CryptAcquireContext usage

We don't actually need a 'full' cryptographic service provider (CSP),
only a 'verify' context to generate random bytes.

Change to request only a 'verify' context; this simplifies the
possible error cases and seems to solve some intermittent failures to
acquire a CSP on commit-validation jobs.

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

show more ...

a12f980013-Jan-2016 Trond Norbye <trond.norbye@gmail.com>

MB-17002: Remove raciness in Couchbase::Thread.start()

Change-Id: I3899cf3f4002b0d74bbe2055373fbcbc06937b0e
Reviewed-on: http://review.couchbase.org/58568
Reviewed-by: Dave Rigby <da

MB-17002: Remove raciness in Couchbase::Thread.start()

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

show more ...

f5ea224904-Feb-2016 Trond Norbye <trond.norbye@gmail.com>

Add to_string to convert json to string

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

Add to_string to convert json to string

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

show more ...

49a09ba112-Jan-2016 Trond Norbye <trond.norbye@gmail.com>

Revert "MB-17002: Remove raciness in Couchbase::Thread.start()"

This patch needs a corresponding memcached patch before it may be merged

Change-Id: I7e7fe3eb563d0b4d6dd0af2e734828e9

Revert "MB-17002: Remove raciness in Couchbase::Thread.start()"

This patch needs a corresponding memcached patch before it may be merged

Change-Id: I7e7fe3eb563d0b4d6dd0af2e734828e9a26f234b
Reviewed-on: http://review.couchbase.org/58543
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>

show more ...

1656425312-Jan-2016 Trond Norbye <trond.norbye@gmail.com>

MB-17002: Remove raciness in Couchbase::Thread.start()

Change-Id: Ieff687fd70ea43f8e077a0d6c7ac9faf6184520b
Reviewed-on: http://review.couchbase.org/58535
Tested-by: buildbot <build@

MB-17002: Remove raciness in Couchbase::Thread.start()

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

show more ...

23b4c6b630-Dec-2015 Trond Norbye <trond.norbye@gmail.com>

Add methods to base64 encode/decode (RFC-4648)

The code implements Base64 encoding and decoding as described
in https://www.ietf.org/rfc/rfc4648.txt

The methods is needed to imp

Add methods to base64 encode/decode (RFC-4648)

The code implements Base64 encoding and decoding as described
in https://www.ietf.org/rfc/rfc4648.txt

The methods is needed to implement SCAM-SHA1 for cbsasl

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

show more ...

feec6c8621-Dec-2015 Volker Mische <vmx@couchbase.com>

Memory leak fix

This leak was found with Clang's analyzer `scan-build`

Change-Id: I4b2407b84836874c34f275e3cd4179965b844863
Reviewed-on: http://review.couchbase.org/58003
Re

Memory leak fix

This leak was found with Clang's analyzer `scan-build`

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

show more ...

12345678