Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable address and leak detection on all debug builds #82

Merged
merged 4 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_compile_options($<$<CONFIG:Debug>:-fsanitize=undefined>)
add_link_options($<$<CONFIG:Debug>:-fsanitize=undefined>)

add_compile_options($<$<CONFIG:Debug>:-fsanitize=address>)
add_link_options($<$<CONFIG:Debug>:-fsanitize=address>)

option(
SUBSTRAIT_CPP_BUILD_TESTING
"Enable substrait-cpp tests. This will enable all other build options automatically."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,15 @@ ::substrait::proto::Type SubstraitPlanTypeVisitor::typeToProto(
}
case TypeKind::kVarchar: {
auto varChar =
reinterpret_cast<const ParameterizedFixedChar*>(&decodedType);
reinterpret_cast<const ParameterizedVarchar*>(&decodedType);
if (varChar == nullptr) {
break;
}
try {
if (!varChar->length()->isInteger()) {
errorListener_->addError(ctx->getStart(), "Missing varchar length.");
break;
}
int32_t length = std::stoi(varChar->length()->value());
type.mutable_varchar()->set_length(length);
} catch (...) {
Expand Down
7 changes: 6 additions & 1 deletion src/substrait/type/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ ParameterizedTypePtr ParameterizedType::decode(

const auto& leftAngleBracketPos = matchingType.find('<');
if (leftAngleBracketPos == std::string::npos) {
bool nullable = matchingType.back() == '?';
bool nullable;
if (matchingType.empty()) {
nullable = false;
} else {
nullable = matchingType.back() == '?';
}
// deal with type and with a question mask like "i32?".
const auto& baseType = nullable
? matchingType = matchingType.substr(0, questionMaskPos)
Expand Down