bustub
bustub copied to clipboard
Valgrind bug
It seems that the valgrind used by GradeScope Autograder is too old or corrupted.
A valgrind: Unrecognised instruction error would occur if you call std::unordered_map::reserve. I call this in LRUReplacer to pre-reserve some space for the std::unordered_map container used in my LRU implementation.
Below is the error info dumped out by valgrind:
Starting memory test: grading_hash_table_verification_test
b'Running main() from gmock_main.cc\n
[==========] Running 1 test from 1 test suite.\n
[----------] Global test environment set-up.\n
[----------] 1 test from HashTableVerificationTest\n
[ RUN ] HashTableVerificationTest.DiskManagerTest\n'
b"==6441== Memcheck, a memory error detector\n
==6441== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.\n
==6441== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info\n
==6441== Command: ./grading_hash_table_verification_test\n
==6441== \n
vex amd64->IR: unhandled instruction bytes: 0x62 0xF3 0xFD 0x8 0xB 0xC0 0xA 0xC5 0xF9 0x2E\n
vex amd64->IR: REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0\n
vex amd64->IR: VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=NONE\n
vex amd64->IR: PFX.66=0 PFX.F2=0 PFX.F3=0\n
==6441== valgrind: Unrecognised instruction at address 0x4f2432c.\n
==6441== at 0x4F2432C: std::__detail::_Rehash_base<int, std::pair<int const, std::_List_iterator<int> >, std::allocator<std::pair<int const, std::_List_iterator<int> > >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true>, std::integral_constant<bool, true> >::reserve(unsigned long) (in /autograder/bustub/build/lib/libbustub_shared.so)\n
==6441== by 0x4F23FDA: std::unordered_map<int, std::_List_iterator<int>, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, std::_List_iterator<int> > > >::reserve(unsigned long) (in /autograder/bustub/build/lib/libbustub_shared.so)\n\
==6441== by 0x4F238E1: bustub::LRUReplacer::LRUReplacer(unsigned long) (in /autograder/bustub/build/lib/libbustub_shared.so)\n
==6441== by 0x4F1F457: bustub::BufferPoolManagerInstance::BufferPoolManagerInstance(unsigned long, unsigned int, unsigned int, bustub::DiskManager*, bustub::LogManager*) (in /autograder/bustub/build/lib/libbustub_shared.so)\n
==6441== by 0x4F1F297: bustub::BufferPoolManagerInstance::BufferPoolManagerInstance(unsigned long, bustub::DiskManager*, bustub::LogManager*) (in /autograder/bustub/build/lib/libbustub_shared.so)\n
==6441== by 0x10F284: bustub::HashTableVerificationTest_DiskManagerTest_Test::TestBody() (in /autograder/bustub/build/test/grading_hash_table_verification_test)\n
==6441== by 0x56B97E3: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== by 0x56B0BD8: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== by 0x5684A4B: testing::Test::Run() (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== by 0x568545B: testing::TestInfo::Run() (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== by 0x5685D62: testing::TestSuite::Run() (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== by 0x569510F: testing::internal::UnitTestImpl::RunAllTests() (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== Your program just tried to execute an instruction that Valgrind\n
==6441== did not recognise. There are two possible reasons for this.\n
==6441== 1. Your program has a bug and erroneously jumped to a non-code\n
==6441== location. If you are running Memcheck and you just saw a\n
==6441== warning about a bad jump, it's probably your program's fault.\n
==6441== 2. The instruction is legitimate but Valgrind doesn't handle it,\n
==6441== i.e. it's Valgrind's fault. If you think this is the case or\n
==6441== you are not sure, please let us know and we'll try to fix it.\n
==6441== Either way, Valgrind will now raise a SIGILL signal which will\n
==6441== probably kill your program.\n
==6441== \n
==6441== Process terminating with default action of signal 4 (SIGILL)\n
==6441== Illegal opcode at address 0x4F2432C\n
==6441== at 0x4F2432C: std::__detail::_Rehash_base<int, std::pair<int const, std::_List_iterator<int> >, std::allocator<std::pair<int const, std::_List_iterator<int> > >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true>, std::integral_constant<bool, true> >::reserve(unsigned long) (in /autograder/bustub/build/lib/libbustub_shared.so)\n
==6441== by 0x4F23FDA: std::unordered_map<int, std::_List_iterator<int>, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, std::_List_iterator<int> > > >::reserve(unsigned long) (in /autograder/bustub/build/lib/libbustub_shared.so)\n
==6441== by 0x4F238E1: bustub::LRUReplacer::LRUReplacer(unsigned long) (in /autograder/bustub/build/lib/libbustub_shared.so)\n
==6441== by 0x4F1F457: bustub::BufferPoolManagerInstance::BufferPoolManagerInstance(unsigned long, unsigned int, unsigned int, bustub::DiskManager*, bustub::LogManager*) (in /autograder/bustub/build/lib/libbustub_shared.so)\n
==6441== by 0x4F1F297: bustub::BufferPoolManagerInstance::BufferPoolManagerInstance(unsigned long, bustub::DiskManager*, bustub::LogManager*) (in /autograder/bustub/build/lib/libbustub_shared.so)\n
==6441== by 0x10F284: bustub::HashTableVerificationTest_DiskManagerTest_Test::TestBody() (in /autograder/bustub/build/test/grading_hash_table_verification_test)\n
==6441== by 0x56B97E3: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== by 0x56B0BD8: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== by 0x5684A4B: testing::Test::Run() (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== by 0x568545B: testing::TestInfo::Run() (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== by 0x5685D62: testing::TestSuite::Run() (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== by 0x569510F: testing::internal::UnitTestImpl::RunAllTests() (in /autograder/bustub/build/lib/libgtest.so.1.11.0)\n
==6441== \n
==6441== HEAP SUMMARY:\n
==6441== in use at exit: 35,787 bytes in 42 blocks\n
==6441== total heap usage: 205 allocs, 163 frees, 157,040 bytes allocated\n
==6441== \n==6441== LEAK SUMMARY:\n
==6441== definitely lost: 0 bytes in 0 blocks\n
==6441== indirectly lost: 0 bytes in 0 blocks\n
==6441== possibly lost: 0 bytes in 0 blocks\n
==6441== still reachable: 35,787 bytes in 42 blocks\n
==6441== of which reachable via heuristic:\n
==6441== newarray : 12,776 bytes in 1 blocks\n
==6441== suppressed: 0 bytes in 0 blocks\n
==6441== Reachable blocks (those to which a pointer was found) are not shown.\n
==6441== To see them, rerun with: --leak-check=full --show-leak-kinds=all\n
==6441== \n
==6441== For counts of detected and suppressed errors, rerun with: -v\n
==6441== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)\n"
Test Failed: False is not true : Valgrind returned error exitcode.
This error is not reproducible on my own computer in which the 3.15.0-version valgrind is being used. In contrast, the version of the valgrind used by autograder is 3.13.0.