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

Copy input in json_parse to avoid ASAN error #7858

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 4 additions & 3 deletions velox/functions/prestosql/JsonFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ class JsonParseFunction : public exec::VectorFunction {
// validation of JSON syntax that doesn't allocate memory or copy data.
assert(args.size() > 0);
const auto& arg = args[0];
static_assert(simdjson::SIMDJSON_PADDING <= AlignedBuffer::kPaddedSize);
if (arg->isConstantEncoding()) {
auto value = arg->as<ConstantVector<StringView>>()->valueAt(0);
auto parsed = parser_.parse(value.data(), value.size(), false);
// Ask the parser to copy the input in case `value' is inlined.
auto parsed = parser_.parse(value.data(), value.size(), true);
if (parsed.error() != simdjson::SUCCESS) {
context.setErrors(rows, errors_[parsed.error()]);
return;
Expand All @@ -104,7 +104,8 @@ class JsonParseFunction : public exec::VectorFunction {

rows.applyToSelected([&](auto row) {
auto value = flatInput->valueAt(row);
auto parsed = parser_.parse(value.data(), value.size(), false);
// Ask the parser to copy the input in case `value' is inlined.
auto parsed = parser_.parse(value.data(), value.size(), true);
if (parsed.error() != simdjson::SUCCESS) {
context.setVeloxExceptionError(row, errors_[parsed.error()]);
}
Expand Down