• Veselin Georgiev's avatar
    Fix SIGBUS due to unaligned access · 748a652f
    Veselin Georgiev authored
    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: 's avatarVeselin Georgiev <veselin.georgiev@garmin.com>
    Signed-off-by: 's avatarJoshua Watt <Joshua.Watt@garmin.com>
    748a652f
Name
Last commit
Last update
..
CMakeLists.txt Loading commit data...
allocatorstest.cpp Loading commit data...
bigintegertest.cpp Loading commit data...
cursorstreamwrappertest.cpp Loading commit data...
documenttest.cpp Loading commit data...
dtoatest.cpp Loading commit data...
encodedstreamtest.cpp Loading commit data...
encodingstest.cpp Loading commit data...
filestreamtest.cpp Loading commit data...
fwdtest.cpp Loading commit data...
istreamwrappertest.cpp Loading commit data...
itoatest.cpp Loading commit data...
jsoncheckertest.cpp Loading commit data...
namespacetest.cpp Loading commit data...
ostreamwrappertest.cpp Loading commit data...
pointertest.cpp Loading commit data...
prettywritertest.cpp Loading commit data...
readertest.cpp Loading commit data...
regextest.cpp Loading commit data...
schematest.cpp Loading commit data...
simdtest.cpp Loading commit data...
strfunctest.cpp Loading commit data...
stringbuffertest.cpp Loading commit data...
strtodtest.cpp Loading commit data...
unittest.cpp Loading commit data...
unittest.h Loading commit data...
valuetest.cpp Loading commit data...
writertest.cpp Loading commit data...