adonis0147 opened a new issue, #13884: URL: https://github.com/apache/doris/issues/13884
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/incubator-doris/issues?q=is%3Aissue) and found no similar issues. ### Version master (3924ecead512f62f28e2d5f3e2cb42a279ca7d9a) ### What's Wrong? ```cpp Status BinaryPrefixPageDecoder::seek_at_or_after_value(const void* value, bool* exact_match) { DCHECK(_parsed); Slice target = *reinterpret_cast<const Slice*>(value); ... ``` In this function, we cast `value` to the type `Slice`. In the function [SegmentIterator::_lookup_ordinal_from_pk_index#L516](https://github.com/apache/doris/blob/master/be/src/olap/rowset/segment_v2/segment_iterator.cpp#L516) ```cpp Status SegmentIterator::_lookup_ordinal_from_pk_index(const RowCursor& key, bool is_include, rowid_t* rowid) { DCHECK(_segment->_tablet_schema->keys_type() == UNIQUE_KEYS); const PrimaryKeyIndexReader* pk_index_reader = _segment->get_primary_key_index(); DCHECK(pk_index_reader != nullptr); std::string index_key; encode_key_with_padding<RowCursor, true, true>( &index_key, key, _segment->_tablet_schema->num_key_columns(), is_include); if (index_key < _segment->min_key()) { *rowid = 0; return Status::OK(); } else if (index_key > _segment->max_key()) { *rowid = num_rows(); return Status::OK(); } bool exact_match = false; std::unique_ptr<segment_v2::IndexedColumnIterator> index_iterator; RETURN_IF_ERROR(pk_index_reader->new_iterator(&index_iterator)); Status status = index_iterator->seek_at_or_after(&index_key, &exact_match); ... ``` We pass `&index_key` (`std::string*`) to `IndexedColumnIterator::seek_at_or_after` and we reach the function `BinaryPrefixPageDecoder::seek_at_or_after_value` finally. The type casting isn't proper but it works well with **libstdc++**. However, the wrong type casting exposes the problems when we use **libc++**, ### What You Expected? Fix the wrong type casting. ### How to Reproduce? ```shell $ ./run-be-ut.sh --run --filter='SegmentReaderWriterTest.normal' ``` **GDB** ```gdb (gdb) set args --gtest_filter="SegmentReaderWriterTest.normal" (gdb) b segment_test.cpp:274 if keys_type == 1 && opts.enable_unique_key_merge_on_write Breakpoint 1 at 0xe141762: segment_test.cpp:274. (2 locations) (gdb) r (gdb) b BinaryPrefixPageDecoder::seek_at_or_after_value (gdb) c Continuing. (gdb) bt #0 doris::segment_v2::BinaryPrefixPageDecoder::seek_at_or_after_value (this=0x60d00003a6a0, value=0x7ffff4e86a80, exact_match=0x7ffff4e86b40) at /Programs/doris/be/src/olap/rowset/segment_v2/binary_prefix_page.cpp:174 #1 0x0000555566fc17cf in doris::segment_v2::IndexedColumnIterator::seek_at_or_after (this=0x6120000c70c0, key=0x7ffff4e86a80, exact_match=0x7ffff4e86b40) at /Programs/doris/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp:199 #2 0x000055556706d83f in doris::segment_v2::SegmentIterator::_lookup_ordinal_from_pk_index (this=0x619000431280, key=..., is_include=false, rowid=0x7ffff4e862d0) at /Programs/doris/be/src/olap/rowset/segment_v2/segment_iterator.cpp:516 #3 0x000055556706a22c in doris::segment_v2::SegmentIterator::_lookup_ordinal (this=0x619000431280, key=..., is_include=false, upper_bound=4096, rowid=0x7ffff4e862d0) at /Programs/doris/be/src/olap/rowset/segment_v2/segment_iterator.cpp:425 #4 0x00005555670626a1 in doris::segment_v2::SegmentIterator::_get_row_ranges_by_keys (this=0x619000431280) at /Programs/doris/be/src/olap/rowset/segment_v2/segment_iterator.cpp:228 #5 0x000055556705fa4a in doris::segment_v2::SegmentIterator::_init (this=0x619000431280, is_vec=false) at /Programs/doris/be/src/olap/rowset/segment_v2/segment_iterator.cpp:184 #6 0x0000555567070634 in doris::segment_v2::SegmentIterator::next_batch (this=0x619000431280, block=0x7ffff53053b0) at /Programs/doris/be/src/olap/rowset/segment_v2/segment_iterator.cpp:600 #7 0x00005555636957ff in doris::segment_v2::SegmentReaderWriterTest_normal_Test::TestBody (this=0x6040003f2410) at /Programs/doris/be/test/olap/rowset/segment_v2/segment_test.cpp:274 #8 0x0000555577d02e33 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) () #9 0x0000555577cfcdd5 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) () #10 0x0000555577cd3d08 in testing::Test::Run() () #11 0x0000555577cd472c in testing::TestInfo::Run() () #12 0x0000555577cd4fec in testing::TestSuite::Run() () #13 0x0000555577ce46ac in testing::internal::UnitTestImpl::RunAllTests() () #14 0x0000555577d03c3c in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) () #15 0x0000555577cfdd1b in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) () #16 0x0000555577ce2ea1 in testing::UnitTest::Run() () #17 0x0000555563d2ab83 in RUN_ALL_TESTS () at /Programs/doris/thirdparty/installed/include/gtest/gtest.h:2490 #18 0x0000555563d221d8 in main (argc=1, argv=0x7fffffffe358) at /Programs/doris/be/test/testutil/run_all_tests.cpp:56 (gdb) frame 2 (gdb) ptype index_key type = std::string ``` ### Anything Else? _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
