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 5fd3dc93c92 [be](ubsan) fix rowcusor ubsan error (#61153)
5fd3dc93c92 is described below
commit 5fd3dc93c92f0da9f89ecfb67df55c0d1e66032c
Author: yiguolei <[email protected]>
AuthorDate: Mon Mar 9 18:11:41 2026 +0800
[be](ubsan) fix rowcusor ubsan error (#61153)
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
---
be/src/storage/row_cursor.cpp | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/be/src/storage/row_cursor.cpp b/be/src/storage/row_cursor.cpp
index 70ac803da52..4eae802973f 100644
--- a/be/src/storage/row_cursor.cpp
+++ b/be/src/storage/row_cursor.cpp
@@ -116,20 +116,21 @@ Status RowCursor::_init_scan_key(TabletSchemaSPtr schema,
fixed_ptr = _fixed_buf + _schema->column_offset(cid);
FieldType type = column.type();
if (type == FieldType::OLAP_FIELD_TYPE_VARCHAR) {
- Slice* slice = reinterpret_cast<Slice*>(fixed_ptr + 1);
- slice->data = variable_ptr;
- slice->size = scan_keys[cid].length();
+ // Use memcpy to avoid misaligned store on fixed_ptr + 1
+ Slice slice(variable_ptr, scan_keys[cid].length());
+ memcpy(fixed_ptr + 1, &slice, sizeof(Slice));
variable_ptr += scan_keys[cid].length();
} else if (type == FieldType::OLAP_FIELD_TYPE_CHAR) {
- Slice* slice = reinterpret_cast<Slice*>(fixed_ptr + 1);
- slice->data = variable_ptr;
- slice->size = std::max(scan_keys[cid].length(),
static_cast<size_t>(column.length()));
- variable_ptr += slice->size;
+ // Use memcpy to avoid misaligned store on fixed_ptr + 1
+ size_t len = std::max(scan_keys[cid].length(),
static_cast<size_t>(column.length()));
+ Slice slice(variable_ptr, len);
+ memcpy(fixed_ptr + 1, &slice, sizeof(Slice));
+ variable_ptr += len;
} else if (type == FieldType::OLAP_FIELD_TYPE_STRING) {
+ // Use memcpy to avoid misaligned store on fixed_ptr + 1
_schema->mutable_column(cid)->set_long_text_buf(long_text_ptr);
- Slice* slice = reinterpret_cast<Slice*>(fixed_ptr + 1);
- slice->data = *(long_text_ptr);
- slice->size = DEFAULT_TEXT_LENGTH;
+ Slice slice(*(long_text_ptr), DEFAULT_TEXT_LENGTH);
+ memcpy(fixed_ptr + 1, &slice, sizeof(Slice));
++long_text_ptr;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]