Open bbnolauv opened 1 month ago
When I use the Debug default sanitizer (AddressSanitizer), I encounter some relatively hard to reproduce problems. It occurs intermittently.
cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild && cmake --build build
➜ build git:(p0) ✗ make -j$(nproc) hyperloglog_test
Consolidate compiler generated dependencies of target gtest
Consolidate compiler generated dependencies of target bustub_murmur3
Consolidate compiler generated dependencies of target bustub_optimizer
Consolidate compiler generated dependencies of target duckdb_pg_query
[ 0%] Built target bustub_murmur3
[ 1%] Built target gtest
[ 9%] Built target duckdb_pg_query
Consolidate compiler generated dependencies of target fmt
Consolidate compiler generated dependencies of target fort
Consolidate compiler generated dependencies of target bustub_binder
[ 11%] Built target fort
[ 20%] Built target bustub_optimizer
[ 22%] Built target fmt
Consolidate compiler generated dependencies of target bustub_buffer
Consolidate compiler generated dependencies of target bustub_statement
Consolidate compiler generated dependencies of target bustub_catalog
[ 27%] Built target bustub_binder
[ 31%] Built target bustub_buffer
[ 33%] Built target bustub_catalog
[ 37%] Built target bustub_statement
Consolidate compiler generated dependencies of target bustub_common
Consolidate compiler generated dependencies of target bustub_container_disk_hash
Consolidate compiler generated dependencies of target bustub_concurrency
Consolidate compiler generated dependencies of target bustub_execution
[ 38%] Built target bustub_container_disk_hash
[ 40%] Built target bustub_concurrency
[ 42%] Built target bustub_common
Consolidate compiler generated dependencies of target bustub_recovery
Consolidate compiler generated dependencies of target bustub_storage_disk
Consolidate compiler generated dependencies of target bustub_storage_index
[ 44%] Built target bustub_recovery
[ 46%] Built target bustub_storage_disk
[ 50%] Built target bustub_storage_index
[ 66%] Built target bustub_execution
Consolidate compiler generated dependencies of target bustub_storage_page
Consolidate compiler generated dependencies of target bustub_storage_table
Consolidate compiler generated dependencies of target bustub_type
Consolidate compiler generated dependencies of target bustub_planner
[ 68%] Built target bustub_storage_table
[ 75%] Built target bustub_storage_page
Consolidate compiler generated dependencies of target bustub_primer
[ 85%] Built target bustub_type
[ 90%] Built target bustub_planner
Consolidate compiler generated dependencies of target gmock
[ 94%] Built target bustub_primer
[ 94%] Built target gmock
Consolidate compiler generated dependencies of target gmock_main
[ 96%] Built target bustub
[ 98%] Built target gmock_main
[100%] Building CXX object test/CMakeFiles/hyperloglog_test.dir/primer/hyperloglog_test.cpp.o
[100%] Building CXX object test/CMakeFiles/hyperloglog_test.dir/__/tools/backtrace.cpp.o
[100%] Linking CXX executable hyperloglog_test
CMake Error at /usr/share/cmake-3.22/Modules/GoogleTestAddTests.cmake:83 (message):
Error running test executable.
Path: '/home/foo/Codes/bustub-private/build/test/hyperloglog_test'
Result: Segmentation fault
Output:
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/GoogleTestAddTests.cmake:179 (gtest_discover_tests_impl)
make[3]: *** [test/CMakeFiles/hyperloglog_test.dir/build.make:124: test/hyperloglog_test] Error 1
make[3]: *** Deleting file 'test/hyperloglog_test'
make[2]: *** [CMakeFiles/Makefile2:2958: test/CMakeFiles/hyperloglog_test.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:2965: test/CMakeFiles/hyperloglog_test.dir/rule] Error 2
make: *** [Makefile:1005: hyperloglog_test] Error 2
When I execute the make
command again, it may succeed. But when I run the executable, a segmentation fault occurs intermittently.
➜ build git:(p0) ✗ ./test/hyperloglog_test
[1] 3296 segmentation fault ./test/hyperloglog_test
➜ build git:(p0) ✗ ./test/hyperloglog_test
Running main() from gmock_main.cc
[==========] Running 10 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 10 tests from HyperLogLogTest
[ RUN ] HyperLogLogTest.BasicTest1
[ OK ] HyperLogLogTest.BasicTest1 (0 ms)
[ RUN ] HyperLogLogTest.BasicTest2
[ OK ] HyperLogLogTest.BasicTest2 (0 ms)
[ RUN ] HyperLogLogTest.EdgeTest1
[ OK ] HyperLogLogTest.EdgeTest1 (0 ms)
[ RUN ] HyperLogLogTest.EdgeTest2
[ OK ] HyperLogLogTest.EdgeTest2 (0 ms)
[ RUN ] HyperLogLogTest.BasicParallelTest
[ OK ] HyperLogLogTest.BasicParallelTest (45 ms)
[ RUN ] HyperLogLogTest.ParallelTest1
[ OK ] HyperLogLogTest.ParallelTest1 (4550 ms)
[ RUN ] HyperLogLogTest.PrestoBasicTest1
[ OK ] HyperLogLogTest.PrestoBasicTest1 (0 ms)
[ RUN ] HyperLogLogTest.PrestoCase1
[ OK ] HyperLogLogTest.PrestoCase1 (0 ms)
[ RUN ] HyperLogLogTest.PrestoCase2
[ OK ] HyperLogLogTest.PrestoCase2 (0 ms)
[ RUN ] HyperLogLogTest.PrestoEdgeCase
[ OK ] HyperLogLogTest.PrestoEdgeCase (0 ms)
[----------] 10 tests from HyperLogLogTest (4597 ms total)
[----------] Global test environment tear-down
[==========] 10 tests from 1 test suite ran. (4597 ms total)
[ PASSED ] 10 tests.
I tried to debug it using gdb but didn't find any useful information that I could understand.
[Thread 0x7fe2aa600640 (LWP 27559) exited]
[Thread 0x7fe2a9c00640 (LWP 27560) exited]
[Thread 0x7fe2a9200640 (LWP 27561) exited]
[ OK ] HyperLogLogTest.ParallelTest1 (6956 ms)
[ RUN ] HyperLogLogTest.PrestoBasicTest1
[ OK ] HyperLogLogTest.PrestoBasicTest1 (0 ms)
[ RUN ] HyperLogLogTest.PrestoCase1
[ OK ] HyperLogLogTest.PrestoCase1 (0 ms)
[ RUN ] HyperLogLogTest.PrestoCase2
[ OK ] HyperLogLogTest.PrestoCase2 (0 ms)
[ RUN ] HyperLogLogTest.PrestoEdgeCase
[ OK ] HyperLogLogTest.PrestoEdgeCase (0 ms)
[----------] 10 tests from HyperLogLogTest (7018 ms total)
[----------] Global test environment tear-down
[==========] 10 tests from 1 test suite ran. (7018 ms total)
[ PASSED ] 10 tests.
==15449==LeakSanitizer has encountered a fatal error.
==15449==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==15449==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
[Inferior 1 (process 15449) exited with code 01]
(gdb) bt
No stack.
(gdb)
I guess this might be related to multithreading, something like a "data race"? But of course, it's just a guess; I still don't know the actual cause.
I also run into this (as a TA) and my solution is to just rerun things until it stops happening. Of course, this is not a long term solution, so once us as a staff have more time we will take a look into this.
Problem
Steps to Reproduce the Problem
build_support/packages.sh
cmake -DCMAKE_BUILD_TYPE=Debug -DBUSTUB_SANITIZER=thread -Bbuild && cmake --build build
cd build && make -j$(nproc) hyperloglog_test
Specifications
#40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2