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

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new d9405529985 [fix](chore) fix DCHECK failure of BufferWritable if 
failed to alloc memory (#35345)
d9405529985 is described below

commit d94055299856f90d84df400f0fb94cb93b21997b
Author: TengJianPing <18241664+jackte...@users.noreply.github.com>
AuthorDate: Sat May 25 00:25:12 2024 +0800

    [fix](chore) fix DCHECK failure of BufferWritable if failed to alloc memory 
(#35345)
---
 be/src/vec/common/string_buffer.hpp | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/be/src/vec/common/string_buffer.hpp 
b/be/src/vec/common/string_buffer.hpp
index 29365579222..8dca6f057a2 100644
--- a/be/src/vec/common/string_buffer.hpp
+++ b/be/src/vec/common/string_buffer.hpp
@@ -41,16 +41,13 @@ public:
         _now_offset += 1;
     }
 
+    // commit may not be called if exception is thrown in writes(e.g. alloc 
mem failed)
     void commit() {
-        auto now_offset = _now_offset;
+        ColumnString::check_chars_length(_offsets.back() + _now_offset, 0);
+        _offsets.push_back(_offsets.back() + _now_offset);
         _now_offset = 0;
-        // the following code may throw exception, and DCHECK in destructor 
will fail if _now_offset is not reset to 0
-        ColumnString::check_chars_length(_offsets.back() + now_offset, 0);
-        _offsets.push_back(_offsets.back() + now_offset);
     }
 
-    ~BufferWritable() { DCHECK(_now_offset == 0); }
-
     template <typename T>
     void write_number(T data) {
         fmt::memory_buffer buffer;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to