14 Commits

Author SHA1 Message Date
ylavic
5c764d9a81 Tests for Allocators copy by rvalue reference. 2021-04-04 12:51:47 +02:00
ylavic
6bed9b266f Don't define StdAllocator<void> from C++17. 2021-03-30 13:47:04 +02:00
ylavic
02f42604bd Make StdAllocator C++17-20 compatible. 2021-03-28 23:48:14 +02:00
ylavic
2e6f761458 Tests for StdAllocator. 2021-03-16 01:03:04 +01:00
Silas S. Brown
b7734d97c0 Remove unnecessary wording from BSD license not needed for MIT license (fixes #528) 2020-10-09 10:04:27 +01:00
Veselin Georgiev
748a652f04 Fix SIGBUS due to unaligned access
Update RAPIDJSON_ALIGN() to always align on an 8-byte boundary
unless otherwise overridden.

On some platforms (such as ARM), 64-bit items (such as doubles and
64-bit integers) must be aligned to an 8 byte address, even though the
architecture is only 32-bits. On these platforms, MemoryPoolAllocator
must match the malloc() behavior and return a 8 byte aligned allocation.
This eliminates any alignment issues that may occur at the expense of
additional memory overhead.

Failure to do so caused a SIGBUS signal when calling
GenericValue::SetNull(). The size of the data_ member of the
GenericValue class is 16 bytes in 32-bit mode and its constructor
requires an 8-byte aligned access.

While parsing a JSON formatted string using Document::ParseStream(), a
stack object containing GenericValue items was constructed. Since the
stack was 8-byte aligned, the constructor calls would succeed. When the
lifetime of the object ends, SetObjectRaw() is invoked. This triggered
an allocation with 4-byte alignment to which the previously 8-byte
aligned GenericValue array was copied. After this, any call to a
GenericValue API that triggered the constructor and thus the placement
new operation on the Data type member would trigger a SIGBUS.

Signed-off-by: Veselin Georgiev <veselin.georgiev@garmin.com>
Signed-off-by: Joshua Watt <Joshua.Watt@garmin.com>
2018-07-31 09:02:26 -05:00
Milo Yip
efe4140208 Fix #399 MemoryPoolAllocator::Realloc expands fail 2016-02-03 00:22:25 +08:00
Milo Yip
74c8dcfd57 Fix clang -Weverything 2015-12-18 18:34:04 +08:00
Milo Yip
311b48224f Try to fix incorrect 64-bit alignment
Added unit tests for alignment macros.
Fixes #418
2015-09-01 10:05:33 +08:00
miloyip
1c98609ada Standardize MemoryPoolAllocator::Realloc() also, and improve coverage 2015-05-03 21:23:13 +08:00
miloyip
8d39282af5 Update license headers for tests 2015-04-18 21:41:38 +08:00
Milo Yip
0e8bbe5e3e Standardize behavior of CrtAllocator::Malloc() 2015-04-17 13:01:14 +08:00
miloyip
a7763cbeca Fix allocator test 2015-04-16 09:42:22 +08:00
miloyip
3f7a3bcc04 Add separate allocators test 2015-04-14 10:19:05 +08:00