Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Fix asan check failures #9520

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Oct 11, 2024

What problem does this PR solve?

Issue Number: ref #9032

Problem Summary:

https://ci.pingcap.net/blue/rest/organizations/jenkins/pipelines/tiflash-sanitizer-daily/runs/2195/nodes/86/log/?start=0

The class DAGQueryInfo only keep reference to the query. So when writing unit test case, it is easy for us to pass a temporary variable and construct a DAGQueryInfo on the temporary variables. That cause stack-use-after-scope error.

struct DAGQueryInfo
{
DAGQueryInfo(
const google::protobuf::RepeatedPtrField<tipb::Expr> & filters_,
const tipb::ANNQueryInfo & ann_query_info_,
const google::protobuf::RepeatedPtrField<tipb::Expr> & pushed_down_filters_,
const TiDB::ColumnInfos & source_columns_,
const std::vector<int> & runtime_filter_ids_,
const int rf_max_wait_time_ms_,
const TimezoneInfo & timezone_info_)
: source_columns(source_columns_)
, filters(filters_)
, ann_query_info(ann_query_info_)
, pushed_down_filters(pushed_down_filters_)
, runtime_filter_ids(runtime_filter_ids_)
, rf_max_wait_time_ms(rf_max_wait_time_ms_)
, timezone_info(timezone_info_){};
// A light copy of tipb::TableScan::columns from TiDB, some attributes are empty, like name.
const TiDB::ColumnInfos & source_columns;
// filters in dag request
const google::protobuf::RepeatedPtrField<tipb::Expr> & filters;
// filters for approximate nearest neighbor (ann) vector search
const tipb::ANNQueryInfo & ann_query_info;
// filters have been push down to storage engine in dag request
const google::protobuf::RepeatedPtrField<tipb::Expr> & pushed_down_filters;
const std::vector<int> & runtime_filter_ids;
const int rf_max_wait_time_ms;
const TimezoneInfo & timezone_info;

[2024-10-10T19:09:42.918Z] ==53983==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7f98b52a4c88 at pc 0x559a56ea95db bp 0x7fff3e8cca50 sp 0x7fff3e8cca48
[2024-10-10T19:09:42.918Z] READ of size 4 at 0x7f98b52a4c88 thread T0
[2024-10-10T19:09:42.918Z]     #0 0x559a56ea95da in tipb::ANNQueryInfo::_internal_query_type() const /home/jenkins/agent/workspace/tiflash-sanitizer-daily/tiflash/build-ASan/contrib/tipb/cpp/tipb/executor.pb.h:10480:46
[2024-10-10T19:09:42.918Z]     #1 0x559a56ea95da in tipb::ANNQueryInfo::query_type() const /home/jenkins/agent/workspace/tiflash-sanitizer-daily/tiflash/build-ASan/contrib/tipb/cpp/tipb/executor.pb.h:10484:10
[2024-10-10T19:09:42.918Z]     #2 0x559a56ea95da in DB::DM::RSOperator::build(std::__1::unique_ptr<DB::DAGQueryInfo, std::__1::default_delete<DB::DAGQueryInfo>> const&, std::__1::vector<TiDB::ColumnInfo, std::__1::allocator<TiDB::ColumnInfo>> const&, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine>> const&, bool, std::__1::shared_ptr<DB::Logger> const&) /home/jenkins/agent/workspace/tiflash-sanitizer-daily/tiflash/dbms/src/Storages/DeltaMerge/Filter/RSOperator.cpp:88:35
[2024-10-10T19:09:42.918Z]     #3 0x559a56e9832a in DB::DM::PushDownFilter::build(DB::SelectQueryInfo const&, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine>> const&, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine>> const&, DB::Context const&, std::__1::shared_ptr<DB::Logger> const&) /home/jenkins/agent/workspace/tiflash-sanitizer-daily/tiflash/dbms/src/Storages/DeltaMerge/Filter/PushDownFilter.cpp:171:30
[2024-10-10T19:09:42.918Z]     #4 0x559a5be8a451 in DB::StorageDeltaMerge::read(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, DB::SelectQueryInfo const&, DB::Context const&, DB::QueryProcessingStage::Enum&, unsigned long, unsigned int) /home/jenkins/agent/workspace/tiflash-sanitizer-daily/tiflash/dbms/src/Storages/StorageDeltaMerge.cpp:837:19
[2024-10-10T19:09:42.918Z]     #5 0x559a59b8733f in DB::MockStorage::getStreamFromDeltaMerge(DB::Context&, long, DB::FilterConditions const*, bool, std::__1::vector<int, std::__1::allocator<int>>, int) /home/jenkins/agent/workspace/tiflash-sanitizer-daily/tiflash/dbms/src/Debug/MockStorage.cpp:241:42
[2024-10-10T19:09:42.918Z]     #6 0x559a402f4a09 in DB::tests::MockStorageTestRunner_DeltaMergeStorageBasic_Test::TestBody() /home/jenkins/agent/workspace/tiflash-sanitizer-daily/tiflash/dbms/src/Flash/tests/gtest_mock_storage.cpp:44:28
[2024-10-10T19:09:42.918Z]     #7 0x559a578e7771 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/jenkins/agent/workspace/tiflash-sanitizer-daily/tiflash/contrib/googletest/googletest/src/gtest.cc:2443:10
...

What is changed and how it works?


Use local variable instead of temporary variable to eliminate the "stack-use-after-scope" warning

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue labels Oct 11, 2024
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Oct 11, 2024
Copy link
Contributor

ti-chi-bot bot commented Oct 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: breezewish, Lloyd-Pottiger

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Lloyd-Pottiger,breezewish]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 11, 2024
Copy link
Contributor

ti-chi-bot bot commented Oct 11, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-10-11 11:31:55.283149794 +0000 UTC m=+11512.432059619: ☑️ agreed by Lloyd-Pottiger.
  • 2024-10-11 14:02:17.418384413 +0000 UTC m=+20534.567294244: ☑️ agreed by breezewish.

@ti-chi-bot ti-chi-bot bot merged commit acfba93 into pingcap:master Oct 11, 2024
5 checks passed
@JaySon-Huang JaySon-Huang deleted the fix_asan_failures branch October 12, 2024 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants