mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Avoid abort in protobuf library in debug build
This commit is contained in:
parent
fbb22348ea
commit
2cde63a25c
@ -41,8 +41,19 @@ public:
|
||||
return descriptor;
|
||||
|
||||
const auto * file_descriptor = importer.Import(schema_path);
|
||||
// If there are parsing errors, AddError() throws an exception and in this case the following line
|
||||
// isn't executed.
|
||||
if (error)
|
||||
{
|
||||
auto info = error.value();
|
||||
error.reset();
|
||||
throw Exception(
|
||||
ErrorCodes::CANNOT_PARSE_PROTOBUF_SCHEMA,
|
||||
"Cannot parse '{}' file, found an error at line {}, column {}, {}",
|
||||
info.filename,
|
||||
std::to_string(info.line),
|
||||
std::to_string(info.column),
|
||||
info.message);
|
||||
}
|
||||
|
||||
assert(file_descriptor);
|
||||
|
||||
if (with_envelope == WithEnvelope::No)
|
||||
@ -74,14 +85,24 @@ private:
|
||||
// Overrides google::protobuf::compiler::MultiFileErrorCollector:
|
||||
void AddError(const String & filename, int line, int column, const String & message) override
|
||||
{
|
||||
throw Exception(ErrorCodes::CANNOT_PARSE_PROTOBUF_SCHEMA,
|
||||
"Cannot parse '{}' file, found an error at line {}, column {}, {}",
|
||||
filename, std::to_string(line), std::to_string(column), message);
|
||||
/// Protobuf library code is not exception safe, we should
|
||||
/// remember error and throw in later from our side.
|
||||
error = ErrorInfo{filename, line, column, message};
|
||||
}
|
||||
|
||||
google::protobuf::compiler::DiskSourceTree disk_source_tree;
|
||||
google::protobuf::compiler::Importer importer;
|
||||
const WithEnvelope with_envelope;
|
||||
|
||||
struct ErrorInfo
|
||||
{
|
||||
String filename;
|
||||
int line;
|
||||
int column;
|
||||
String message;
|
||||
};
|
||||
|
||||
std::optional<ErrorInfo> error;
|
||||
};
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
18
tests/queries/0_stateless/02705_protobuf_debug_abort.sh
Executable file
18
tests/queries/0_stateless/02705_protobuf_debug_abort.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-fasttest
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
echo 'syntax = "proto3";
|
||||
|
||||
message Message {
|
||||
NotExisted x = 1;
|
||||
}' > 02705_schema.proto
|
||||
|
||||
|
||||
$CLICKHOUSE_LOCAL -q "select * from file(data.bin, Protobuf) settings format_schema='schema:Message'" 2>&1 | grep -c "CANNOT_PARSE_PROTOBUF_SCHEMA"
|
||||
|
||||
rm 02705_schema.proto
|
||||
|
Loading…
Reference in New Issue
Block a user