Skip to content

Commit 272cb10

Browse files
committed
Updated next release date
Synchronize cmake macros with yggcpp Fix undefined behavior errors
1 parent f1ee6fd commit 272cb10

5 files changed

Lines changed: 64 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ Because YggdrasilRapidJSON continues to merge updates from RapidJSON, the RapidJ
55

66
## X.X.X.X - XXXX-XX-XX
77

8-
## 1.1.0.4 - 2026-06-25
8+
## 1.1.0.4 - 2026-07-06
99

1010
### Bug fixes
1111
* Fix bug where version could not be set in the conda recipe build since it is created from a tar instead of the git repo
1212
* Fix bug where asan flags were added to list that could be used for Fortran, but are only valid for C or CXX
1313
* Fix bug where string without encoding specified did not validate against a schema specifying ASCII encoding
1414
* Fix bug in ObjWavefront get_int_array where dec parameter was not passed at the correct position resulting in arrays that were 1 indexed even when dec was true
15+
* Fix places where undefined behavior was possible with use of pointer allocator
1516

1617
### Maintenance
1718
* Update names of flag/library lists set based on options to adhere to pattern of <PREFIX>_PUBLIC/PRIVATE_<SUFFIX>

YggdrasilRapidJSONMacros.cmake

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,27 @@ function(yggdrasil_rapidjson_config_vars PREFIX)
7878
set(${PREFIX}_CONFIG_VARS ${${PREFIX}_CONFIG_VARS} PARENT_SCOPE)
7979
endfunction()
8080

81-
macro(yggdrasil_rapidjson_config_init PREFIX)
81+
function(yggdrasil_rapidjson_config_init PREFIX)
8282
yggdrasil_rapidjson_config_vars(${PREFIX})
8383
foreach(var IN LISTS ${PREFIX}_CONFIG_VARS)
84-
set(${var})
84+
set(${var} "" PARENT_SCOPE)
8585
endforeach()
86-
endmacro()
86+
endfunction()
8787

88-
macro(yggdrasil_rapidjson_config_cleanup PREFIX)
88+
function(yggdrasil_rapidjson_config_cleanup PREFIX)
8989
if(${PREFIX}_CONFIG_VARS)
9090
foreach(var IN LISTS ${PREFIX}_CONFIG_VARS)
91-
unset(${var})
91+
unset(${var} PARENT_SCOPE)
9292
endforeach()
93-
unset(${PREFIX}_CONFIG_VARS)
93+
unset(${PREFIX}_CONFIG_VARS PARENT_SCOPE)
9494
endif()
95-
endmacro()
95+
endfunction()
9696

97-
macro(yggdrasil_rapidjson_config_show PREFIX LEVEL)
97+
function(yggdrasil_rapidjson_config_show PREFIX LEVEL)
9898
foreach(var IN LISTS ${PREFIX}_CONFIG_VARS)
9999
message(${LEVEL} "${var} = ${${var}}")
100100
endforeach()
101-
endmacro()
101+
endfunction()
102102

103103
function(yggdrasil_rapidjson_config_accum PREFIX)
104104
foreach(suffix LIBRARIES INCLUDE_DIRS COMPILE_FLAGS LINK_FLAGS)
@@ -384,12 +384,13 @@ macro(yggdrasil_rapidjson_options_config OUTPUT_PREFIX)
384384
endforeach()
385385
endif()
386386
if(YGGDRASIL_RAPIDJSON_BUILD_UBSAN)
387-
foreach(_yggdrasil_rapidjson_asan_tool GNU Clang)
387+
foreach(_yggdrasil_rapidjson_asan_tool GNU Clang AppleClang)
388388
list(
389389
APPEND ${OUTPUT_PREFIX}_${_yggdrasil_rapidjson_asan_tool}_ASAN_COMPILE_FLAGS
390390
-fsanitize=undefined
391391
)
392392
endforeach()
393+
# Unsure why this is only set for AppleClang and -fsanitize=undefined was not being set
393394
list(APPEND ${OUTPUT_PREFIX}_AppleClang_ASAN_COMPILE_FLAGS
394395
-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error)
395396
endif()
@@ -450,12 +451,14 @@ function(yggdrasil_rapidjson_gitversion OUTPUT_VARIABLE DEFAULT)
450451
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty --match "v*"
451452
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
452453
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION
454+
ERROR_VARIABLE GIT_DESCRIBE_ERROR
453455
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE
454456
OUTPUT_STRIP_TRAILING_WHITESPACE
455457
)
456458
if(GIT_DESCRIBE_ERROR_CODE)
457459
message(STATUS "Could not locate a git tag, falling back to version ${DEFAULT}")
458460
set(${OUTPUT_VARIABLE} ${DEFAULT})
461+
message(DEBUG "Git output: ${GIT_DESCRIBE_ERROR}")
459462
else()
460463
string(SUBSTRING "${GIT_DESCRIBE_VERSION}" 1 -1 GIT_DESCRIBE_VERSION)
461464
string(FIND "${GIT_DESCRIBE_VERSION}" "-" idx)

include/yggdrasil_rapidjson/pointer.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class GenericPointer {
451451
nameBufferSkip += t->length;
452452

453453
r.tokenCount_ = nCopy;
454-
r.tokens_ = static_cast<Token *>(allocator_->Malloc(r.tokenCount_ * sizeof(Token) + nameBufferSize * sizeof(Ch)));
454+
r.tokens_ = static_cast<Token *>(r.allocator_->Malloc(r.tokenCount_ * sizeof(Token) + nameBufferSize * sizeof(Ch)));
455455
r.nameBuffer_ = reinterpret_cast<Ch *>(r.tokens_ + r.tokenCount_);
456456
if (nCopy > 0) {
457457
std::memcpy(r.tokens_, tokens_ + nSkip, nCopy * sizeof(Token));
@@ -749,7 +749,11 @@ class GenericPointer {
749749
//@}
750750

751751
//! Get the allocator of this pointer.
752-
Allocator& GetAllocator() { return *allocator_; }
752+
Allocator& GetAllocator() {
753+
if (!allocator_)
754+
ownAllocator_ = allocator_ = YGGDRASIL_RAPIDJSON_NEW(Allocator)();
755+
return *allocator_;
756+
}
753757

754758
//!@name Tokens
755759
//@{

include/yggdrasil_rapidjson/schema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13190,8 +13190,8 @@ class GenericSchemaValidator :
1319013190
AddErrorCode(error, code);
1319113191
AddErrorInstanceLocation(error, false);
1319213192
// When appending to a pointer ensure its allocator is used
13193-
PointerType schemaRef = GetInvalidSchemaPointer().Append(SchemaType::GetValidateErrorKeyword(kValidateErrorDependencies), &GetInvalidSchemaPointer().GetAllocator());
13194-
AddErrorSchemaLocation(error, schemaRef.Append(sourceName.GetString(), sourceName.GetStringLength(), &GetInvalidSchemaPointer().GetAllocator()));
13193+
PointerType schemaRef = GetInvalidSchemaPointer().Append(SchemaType::GetValidateErrorKeyword(kValidateErrorDependencies)); // , &GetInvalidSchemaPointer().GetAllocator());
13194+
AddErrorSchemaLocation(error, schemaRef.Append(sourceName.GetString(), sourceName.GetStringLength())); // , &GetInvalidSchemaPointer().GetAllocator()));
1319513195
ValueType wrapper(kObjectType);
1319613196
wrapper.AddMember(ValueType(SchemaType::GetValidateErrorKeyword(code), GetStateAllocator()).Move(), error, GetStateAllocator());
1319713197
currentError_.AddMember(ValueType(sourceName, GetStateAllocator()).Move(), wrapper, GetStateAllocator());

run_tests.sh

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
11
set -e
2-
INSTALL_DIR="$(pwd)/_install"
3-
# rm -rf build
4-
if [ ! -d build ]; then
5-
mkdir build
2+
REBUILD=""
3+
BUILD_DIR=""
4+
INSTALL_DIR=""
5+
while [[ $# -gt 0 ]]; do
6+
case $1 in
7+
--rebuild )
8+
REBUILD="TRUE"
9+
shift
10+
;;
11+
--build-dir )
12+
BUILD_DIR="$2"
13+
shift
14+
shift # past argument with value
15+
;;
16+
--install-dir )
17+
INSTALL_DIR="$2"
18+
shift
19+
shift # past argument with value
20+
;;
21+
esac
22+
done
23+
if [ ! -n "${BUILD_DIR}" ]; then
24+
BUILD_DIR="$(pwd)/build"
25+
fi
26+
if [ ! -n "${INSTALL_DIR}" ]; then
27+
INSTALL_DIR="$(pwd)/_install"
28+
fi
29+
if [ -n "$REBUILD" ]; then
30+
if [ -d ${BUILD_DIR} ]; then
31+
rm -rf ${BUILD_DIR}
32+
fi
33+
fi
34+
if [ ! -d ${BUILD_DIR} ]; then
35+
mkdir ${BUILD_DIR}
636
fi
737
if [ ! -d ${INSTALL_DIR} ]; then
838
mkdir ${INSTALL_DIR}
939
fi
10-
cd build
1140

12-
cmake .. \
41+
cmake -B ${BUILD_DIR} -S $(pwd) \
1342
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
1443
-DYGGDRASIL_RAPIDJSON_SKIP_VALGRIND_TESTS:BOOL=ON \
1544
-DYGGDRASIL_RAPIDJSON_CREATE_METASCHEMA_FULL:BOOL=ON \
@@ -23,28 +52,23 @@ cmake .. \
2352
-DYGGDRASIL_RAPIDJSON_BUILD_EXAMPLES:BOOL=ON \
2453
-DYGGDRASIL_RAPIDJSON_BUILD_DOC:BOOL=OFF
2554
# -DCMAKE_BUILD_TYPE=Debug
26-
# Install in local directory
2755
# -DCMAKE_INSTALL_PREFIX:FILEPATH=${INSTALL_DIR}
2856

2957
# Tests
30-
cmake --build . --target=tests -- -j 8
31-
cmake --install . --prefix "${INSTALL_DIR}"
58+
cmake --build ${BUILD_DIR} --target=tests -- -j 8
59+
cd ${BUILD_DIR}
3260
ctest -R unittest --stop-on-failure
3361
# ctest -R perftest --stop-on-failure
3462

3563
# Examples
36-
# cmake --build . --target=examples -- -j 8
37-
# ./bin/yggdrasil
38-
# ./bin/${example_name}
64+
# cmake --build ${BUILD_DIR} --target=examples -- -j 8
65+
# ${BUILD_DIR}/bin/yggdrasil
66+
# ${BUILD_DIR}/bin/${example_name}
3967

4068
# Install
41-
# cmake --install .
69+
cmake --install ${BUILD_DIR} --prefix "${INSTALL_DIR}"
4270

4371

44-
# # cmake --build . -- -j 8
45-
# cmake --build . --target=tests -- -j 8
46-
# # ctest -C Debug --output-on-failure --verbose --stop-on-failure
47-
# ctest -R unittest --stop-on-failure
4872
# ctest -R coverage
4973
# # cmake .. -DYGGDRASIL_RAPIDJSON_SKIP_VALGRIND_TESTS=ON -DYGGDRASIL_RAPIDJSON_ENABLE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug
5074
# # ctest -T Coverage

0 commit comments

Comments
 (0)