This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new dd880b0ab66 [fix](cloud) fix double free when get_error_log_file_path 
(#41320)
dd880b0ab66 is described below

commit dd880b0ab6665109c53349cade4a3138e2a5fad0
Author: Xin Liao <[email protected]>
AuthorDate: Thu Sep 26 14:20:13 2024 +0800

    [fix](cloud) fix double free when get_error_log_file_path (#41320)
    
    After #40924, `get_error_log_file_path` might be accessed concurrently,
    leading to error_log_file being closed multiple times. Therefore, a lock
    was added to solve this issue.
---
 be/src/runtime/runtime_state.cpp | 1 +
 be/src/runtime/runtime_state.h   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/be/src/runtime/runtime_state.cpp b/be/src/runtime/runtime_state.cpp
index 7ccf73e2f0d..cead9f3aac0 100644
--- a/be/src/runtime/runtime_state.cpp
+++ b/be/src/runtime/runtime_state.cpp
@@ -434,6 +434,7 @@ Status 
RuntimeState::append_error_msg_to_file(std::function<std::string()> line,
 }
 
 std::string RuntimeState::get_error_log_file_path() {
+    std::lock_guard<std::mutex> l(_s3_error_log_file_lock);
     if (_s3_error_fs && _error_log_file && _error_log_file->is_open()) {
         // close error log file
         _error_log_file->close();
diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h
index cae6c4e6403..5b81193dc7d 100644
--- a/be/src/runtime/runtime_state.h
+++ b/be/src/runtime/runtime_state.h
@@ -727,6 +727,7 @@ private:
     std::shared_ptr<io::S3FileSystem> _s3_error_fs;
     // error file path on s3, 
${bucket}/${prefix}/error_log/${label}_${fragment_instance_id}
     std::string _s3_error_log_file_path;
+    std::mutex _s3_error_log_file_lock;
 };
 
 #define RETURN_IF_CANCELLED(state)               \


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to