This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 5a5063be20f25e883bf4a4953f549a99e1fc5acc Author: Pxl <pxl...@qq.com> AuthorDate: Mon Apr 22 18:02:17 2024 +0800 [bug](fix) heap use after free when json parse failed (#33955) --- be/src/vec/exec/format/json/new_json_reader.cpp | 2 +- .../stream_load/load_json_parse_failed/test | 4 ++ .../load_json_parse_failed.groovy | 49 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/be/src/vec/exec/format/json/new_json_reader.cpp b/be/src/vec/exec/format/json/new_json_reader.cpp index 5747fb609ea..9cfa838b592 100644 --- a/be/src/vec/exec/format/json/new_json_reader.cpp +++ b/be/src/vec/exec/format/json/new_json_reader.cpp @@ -1071,7 +1071,7 @@ Status NewJsonReader::_simdjson_handle_simple_json(RuntimeState* /*state*/, Bloc return Status::OK(); } RETURN_IF_ERROR(st); - if (*is_empty_row) { + if (*is_empty_row || *eof) { return Status::OK(); } diff --git a/regression-test/data/load_p0/stream_load/load_json_parse_failed/test b/regression-test/data/load_p0/stream_load/load_json_parse_failed/test new file mode 100644 index 00000000000..295ffe5edc6 --- /dev/null +++ b/regression-test/data/load_p0/stream_load/load_json_parse_failed/test @@ -0,0 +1,4 @@ +{ + "event_id":"a", + "time_stamp":"aa" +} \ No newline at end of file diff --git a/regression-test/suites/load_p0/stream_load/load_json_parse_failed/load_json_parse_failed.groovy b/regression-test/suites/load_p0/stream_load/load_json_parse_failed/load_json_parse_failed.groovy new file mode 100644 index 00000000000..531d90ab9cf --- /dev/null +++ b/regression-test/suites/load_p0/stream_load/load_json_parse_failed/load_json_parse_failed.groovy @@ -0,0 +1,49 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import org.codehaus.groovy.runtime.IOGroovyMethods + +suite ("load_json_parse_failed") { + + sql """ DROP TABLE IF EXISTS test; """ + + sql """ + CREATE TABLE `test` ( + `event_id` varchar(50) NULL, + `time_stamp` varchar(50) NULL, + ) ENGINE=OLAP + DISTRIBUTED BY HASH(`event_id`) BUCKETS AUTO + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + """ + streamLoad { + table "test" + set 'format', 'json' + set 'read_json_by_line', 'true' + file './test' + + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals("fail", json.Status.toLowerCase()) + } + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org