This is an automated email from the ASF dual-hosted git repository. csringhofer pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit 627bbdd2a436ecb1a62825976f6afc2903395af1 Author: Yida Wu <[email protected]> AuthorDate: Sun Mar 16 19:36:08 2025 -0700 IMPALA-13868: Fix ASAN build failed in test_ai_generate_text_exprs In ParseImpalaOptions(), when the input options cannot be parsed, the error message is constructed incorrectly by directly using the StringVal pointer without considering its length. This may result in reading beyond the allocated memory, leading to unexpected behavior. This issue was introduced by IMPALA-13565 and triggered ASAN errors due to new test cases added in IMPALA-13812 (query_test/test_exprs.py). While IMPALA-13565 included unit tests (AiFunctionsTest in expr-test.cc) for this code, the newly added ee tests test_ai_generate_text_exprs() in IMPALA-13812 run in parallel, making it much easier to trigger this issue. The patch fixes the issue by ensuring the error message is constructed using both the pointer and its length. Tests: Passed the ASAN build tests. Change-Id: I9f4656e256bb9b31acc2653c3b910788ddf03f2b Reviewed-on: http://gerrit.cloudera.org:8080/22632 Reviewed-by: Riza Suminto <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- be/src/exprs/ai-functions.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/be/src/exprs/ai-functions.cc b/be/src/exprs/ai-functions.cc index 1ef2b079d..25935b48a 100644 --- a/be/src/exprs/ai-functions.cc +++ b/be/src/exprs/ai-functions.cc @@ -126,7 +126,8 @@ static void ParseImpalaOptions(const StringVal& options, Document& document, if (document.Parse(reinterpret_cast<const char*>(options.ptr), options.len) .HasParseError()) { std::stringstream ss; - ss << "Error parsing impala options: " << reinterpret_cast<const char*>(options.ptr) + ss << "Error parsing impala options: " + << string(reinterpret_cast<const char*>(options.ptr), options.len) << ", error code: " << document.GetParseError() << ", offset input " << document.GetErrorOffset(); throw std::runtime_error(ss.str());
