Skip to content
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
1 change: 1 addition & 0 deletions doc/changes/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ n/a

## Features / Enhancements

- #61: Added stacktrace-aware exceptions and assertions to v2
- #32: Added clang tidy to v2
- #36: Added developer guide for clang-tidy and clang-format
- #38: Added Sonar Qube Public
Expand Down
1 change: 1 addition & 0 deletions udf-runner-cpp/v2/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.3.1
76 changes: 52 additions & 24 deletions udf-runner-cpp/v2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ cc_library(
name = "udf_protocol",
srcs = ["udf_protocol.cc"],
hdrs = ["udf_protocol.hpp", ":udf_protocol_generated"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
# Do not depend on the ordinary runtime headers: the generated protocol
# header must resolve all runtime includes through the isolated copy.
deps = [":private_flatbuffers_runtime"],
Expand All @@ -96,7 +96,7 @@ cc_library(
cc_test(
name = "udf_protocol_test",
srcs = ["udf_protocol_test.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
deps = [
":udf_protocol",
"@googletest//:gtest_main",
Expand All @@ -106,15 +106,15 @@ cc_test(
cc_binary(
name = "udf_protocol_shared",
srcs = ["udf_protocol.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
linkshared = 1,
deps = [":udf_protocol"],
)

cc_test(
name = "udf_protocol_symbol_leak_test",
srcs = ["nm_runner.hpp", "udf_protocol_symbol_leak_test.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
# The test inspects the built shared object with nm. data makes the
# artifact available at runtime and args passes its runfiles path.
data = [":udf_protocol_shared"],
Expand All @@ -126,7 +126,7 @@ cc_test(
cc_test(
name = "udf_protocol_static_symbol_leak_test",
srcs = ["nm_runner.hpp", "udf_protocol_static_symbol_leak_test.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
# cc_library produces multiple artifacts, so the test receives all
# locations and selects the static .a archive for nm inspection.
data = [":udf_protocol"],
Expand All @@ -141,7 +141,7 @@ cc_test(
"flatbuffers_header_order_test.cc",
"flatbuffers_header_order_reverse.cc",
],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
# Compile both include orders against the ordinary runtime and the
# isolated runtime to protect against header-guard and macro collisions.
deps = [":udf_protocol", "@flatbuffers//:runtime_cc"],
Expand All @@ -165,7 +165,7 @@ cc_binary(
srcs = ["arrow_c_data_demo.cc"],
additional_linker_inputs = [":arrow_c_data_demo_exports"],
copts = [
"-std=c++20",
"-std=c++23",
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
],
Expand All @@ -181,7 +181,7 @@ cc_binary(
cc_test(
name = "arrow_core_test",
srcs = ["arrow_core_test.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
deps = [
":arrow_core",
"@googletest//:gtest_main",
Expand All @@ -191,7 +191,7 @@ cc_test(
cc_test(
name = "arrow_c_data_demo_test",
srcs = ["arrow_c_data_demo_test.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
data = [":libarrow_c_data_demo.so"],
args = ["$(location :libarrow_c_data_demo.so)"],
linkopts = ["-ldl"],
Expand All @@ -203,14 +203,15 @@ cc_library(
name = "json_schema",
hdrs = ["include/exasol/udf/v2/json_schema.hpp"],
includes = ["include"],
copts = ["-std=c++23"],
deps = ["@v2_json_schema_validator//:json_schema_validator"],
)

cc_test(
name = "json_schema_validation_test",
srcs = ["json_schema_validation_test.cc"],
data = ["//json_schema:all_schemas"],
copts = ["-std=c++17"],
copts = ["-std=c++23"],
deps = [
":json_schema",
"@googletest//:gtest_main",
Expand All @@ -220,7 +221,7 @@ cc_test(
cc_test(
name = "json_schema_symbol_leak_test",
srcs = ["json_schema_symbol_leak_test.cc"],
copts = ["-std=c++17"],
copts = ["-std=c++23"],
linkopts = ["-ldl"],
target_compatible_with = ["@platforms//os:linux"],
deps = [":json_schema"],
Expand All @@ -231,7 +232,7 @@ cc_fuzz_test(
srcs = ["frame_fuzz_test.cc"],
corpus = glob(["fuzz/corpus/frame/**"]),
dicts = ["fuzz/frame.dict"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
deps = [":udf_protocol"],
tags = ["fuzz-test"],
)
Expand All @@ -241,7 +242,7 @@ cc_fuzz_test(
srcs = ["call_metadata_fuzz_test.cc", "test_utils/json_schema_fuzzing.hpp"],
corpus = glob(["fuzz/corpus/call_metadata/**"]),
dicts = ["fuzz/json.dict"],
copts = ["-std=c++17"],
copts = ["-std=c++23"],
data = ["//json_schema:all_schemas"],
deps = [":json_schema"],
tags = ["fuzz-test"],
Expand All @@ -252,7 +253,7 @@ cc_fuzz_test(
srcs = ["connection_information_fuzz_test.cc", "test_utils/json_schema_fuzzing.hpp"],
corpus = glob(["fuzz/corpus/connection_information/**"]),
dicts = ["fuzz/json.dict"],
copts = ["-std=c++17"],
copts = ["-std=c++23"],
data = ["//json_schema:all_schemas"],
deps = [":json_schema"],
tags = ["fuzz-test"],
Expand All @@ -263,7 +264,7 @@ cc_fuzz_test(
srcs = ["export_specification_fuzz_test.cc", "test_utils/json_schema_fuzzing.hpp"],
corpus = glob(["fuzz/corpus/export_specification/**"]),
dicts = ["fuzz/json.dict"],
copts = ["-std=c++17"],
copts = ["-std=c++23"],
data = ["//json_schema:all_schemas"],
deps = [":json_schema"],
tags = ["fuzz-test"],
Expand All @@ -274,7 +275,7 @@ cc_fuzz_test(
srcs = ["import_specification_fuzz_test.cc", "test_utils/json_schema_fuzzing.hpp"],
corpus = glob(["fuzz/corpus/import_specification/**"]),
dicts = ["fuzz/json.dict"],
copts = ["-std=c++17"],
copts = ["-std=c++23"],
data = ["//json_schema:all_schemas"],
deps = [":json_schema"],
tags = ["fuzz-test"],
Expand All @@ -287,6 +288,7 @@ cc_library(
"include/exasol/udf/v2/spsc_queue.hpp",
],
includes = ["include"],
copts = ["-std=c++23"],
deps = [
"@v2_concurrentqueue//:concurrentqueue",
"@v2_readerwriterqueue//:readerwriterqueue",
Expand All @@ -296,7 +298,7 @@ cc_library(
cc_test(
name = "moodycamel_queues_test",
srcs = ["moodycamel_queues_test.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
deps = [
":moodycamel_queues",
"@googletest//:gtest_main",
Expand All @@ -306,15 +308,15 @@ cc_test(
cc_binary(
name = "moodycamel_queues_shared",
srcs = ["moodycamel_queues_shared.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
linkshared = 1,
deps = [":moodycamel_queues"],
)

cc_test(
name = "moodycamel_symbol_leak_test",
srcs = ["moodycamel_symbol_leak_test.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
data = [":moodycamel_queues_shared"],
args = ["$(location :moodycamel_queues_shared)"],
target_compatible_with = ["@platforms//os:linux"],
Expand All @@ -326,13 +328,14 @@ cc_library(
srcs = ["event_fd.cc"],
hdrs = ["include/exasol/udf/v2/event_fd.hpp"],
includes = ["include"],
copts = ["-std=c++23"],
target_compatible_with = ["@platforms//os:linux"],
)

cc_test(
name = "event_fd_test",
srcs = ["event_fd_test.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
deps = [
":event_fd",
"@googletest//:gtest_main",
Expand All @@ -344,6 +347,7 @@ cc_library(
name = "waitable_queue",
hdrs = ["include/exasol/udf/v2/waitable_queue.hpp"],
includes = ["include"],
copts = ["-std=c++23"],
deps = [
":event_fd",
":moodycamel_queues",
Expand All @@ -354,7 +358,7 @@ cc_library(
cc_test(
name = "waitable_queue_test",
srcs = ["waitable_queue_test.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
deps = [
":waitable_queue",
"@googletest//:gtest",
Expand All @@ -366,7 +370,7 @@ cc_test(
cc_test(
name = "waitable_queue_integration_test",
srcs = ["waitable_queue_integration_test.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
deps = [
":waitable_queue",
"@googletest//:gtest_main",
Expand All @@ -378,7 +382,7 @@ cc_test(
cc_binary(
name = "waitable_queue_benchmark",
srcs = ["waitable_queue_benchmark.cc"],
copts = ["-std=c++20"],
copts = ["-std=c++23"],
deps = [
":waitable_queue",
"@google_benchmark//:benchmark_main",
Expand All @@ -390,8 +394,32 @@ cc_fuzz_test(
name = "queue_fuzz_test",
srcs = ["queue_fuzz_test.cc"],
corpus = glob(["fuzz/corpus/queue/**"]),
copts = ["-std=c++20"],
copts = ["-std=c++23"],
deps = [":waitable_queue"],
tags = ["fuzz-test"],
target_compatible_with = ["@platforms//os:linux"],
)

cc_library(
name = "exception",
srcs = ["assert.cc"],
hdrs = [
"include/exasol/udf/v2/assert.hpp",
"include/exasol/udf/v2/exception.hpp",
],
includes = ["include"],
copts = ["-std=c++23"],
linkopts = ["-lstdc++exp"],
)

cc_test(
name = "exception_test",
srcs = ["exception_test.cc"],
copts = ["-std=c++23"],
tags = ["no-mull"],
deps = [
":exception",
"@googletest//:gtest_main",
],
target_compatible_with = ["@platforms//os:linux"],
)
54 changes: 54 additions & 0 deletions udf-runner-cpp/v2/assert.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <exasol/udf/v2/assert.hpp>

#include <cstdio>
#include <sstream>
#include <utility>

namespace exasol::udf::v2::detail
{

std::string format_stacktrace_entry(const std::size_t frame_number,
const std::string_view description,
const std::string_view source_file,
const std::uint_least32_t source_line)
{
std::ostringstream output;
output << " #" << frame_number << ' ' << description;
if (!source_file.empty())
{
output << " (" << source_file << ':' << source_line << ')';
}
output << '\n';
return output.str();
}

std::string format_assertion_failure(const Exception& error)
{
std::ostringstream output;
output << error.location().file_name() << ':' << error.location().line() << ':'
<< error.location().function_name() << ": " << error.what() << '\n';
std::size_t frame_number = 0;
for (const auto& frame : error.stacktrace())
{
output << format_stacktrace_entry(frame_number, frame.description(), frame.source_file(),
frame.source_line());
++frame_number;
}
return output.str();
}

[[noreturn]] void assertion_failure(const char* expression,
std::source_location location,
const AssertionTerminator& terminator)
{
std::ostringstream message;
message << "Assertion failed: " << expression;
const Exception error(message.str(), location);
const std::string output = format_assertion_failure(error);
static_cast<void>(std::fwrite(output.data(), sizeof(char), output.size(), stderr));
std::fflush(stderr);
terminator();
std::unreachable();
}

} // namespace exasol::udf::v2::detail
Loading
Loading