Skip to content

Commit

Permalink
[yugabyte#17820] YSQL: Fix asan issue in TestDeferrablePagingInSerial…
Browse files Browse the repository at this point in the history
…izableIsolation

Summary:
The following error was seen because `num_write_iterations` was used by
the test thread after it was destructed. The thread should stop before
`num_write_iterations` is destructed.

```
==27369==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7f4570be7660 at pc 0x55b8b47bbe66 bp 0x7f44ec861290 sp 0x7f44ec861288
WRITE of size 8 at 0x7f4570be7660 thread T145
    #0 0x55b8b47bbe65 in unsigned long std::__cxx_atomic_fetch_add[abi:v160006]<unsigned long>(std::__cxx_atomic_base_impl<unsigned long>*, unsigned long, std::memory_order) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20230621185529-6777477baa-almalinux8-x86_64-clang16/installed/asan/libcxx/include/c++/v1/atomic:1014:12
    #1 0x55b8b47bbe65 in std::__atomic_base<unsigned long, true>::fetch_add[abi:v160006](unsigned long, std::memory_order) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20230621185529-6777477baa-almalinux8-x86_64-clang16/installed/asan/libcxx/include/c++/v1/atomic:1649:17
    #2 0x55b8b47bbe65 in yb::pgwrapper::PgSingleTServerTest_TestDeferrablePagingInSerializableIsolation_Test::TestBody()::$_0::operator()() const ${BUILD_ROOT}/../../src/yb/yql/pgwrapper/pg_single_tserver-test.cc:361:32
```
Jira: DB-6908

Test Plan:
Jenkins: test regex: .*single_tserver.*
./yb_build.sh --cxx-test pgwrapper_pg_single_tserver-test --gtest_filter PgSingleTServerTest.TestPagingInSerializableIsolation

Reviewers: dmitry

Reviewed By: dmitry

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D26571
  • Loading branch information
pkj415 committed Jun 30, 2023
1 parent e5b6210 commit 601a0a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/yb/yql/pgwrapper/pg_single_tserver-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ TEST_F_EX(

constexpr auto kWriteNumIterations = 1000u;

TestThreadHolder thread_holder;
CountDownLatch sync_start_latch(2);
std::atomic<size_t> num_write_iterations{0};
TestThreadHolder thread_holder;
thread_holder.AddThreadFunctor(
[this, &stop = thread_holder.stop_flag(), &num_write_iterations, &sync_start_latch]() {
auto write_conn = ASSERT_RESULT(Connect());
Expand Down

0 comments on commit 601a0a3

Please sign in to comment.