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

Type subsystem #5

Open
lmwnshn opened this issue Sep 11, 2019 · 1 comment
Open

Type subsystem #5

lmwnshn opened this issue Sep 11, 2019 · 1 comment
Labels
beginner Good for newcomers. Mark issues with this. beginner-medium Less than two weeks of work for a beginner. best-practice Style fixes or refactor in the code base. Mark issues with this.

Comments

@lmwnshn
Copy link
Collaborator

lmwnshn commented Sep 11, 2019

The type subsystem could probably be cleaned up significantly. Right now, there are a bunch of macros with hardcoded variable names inside them, and a lot of the logic between the different types (e.g. SmallintType vs BigintType) is essentially copy-and-pasted. You could probably replace essentially all the existing type files with a few well-written template functions.

@lmwnshn lmwnshn added beginner Good for newcomers. Mark issues with this. best-practice Style fixes or refactor in the code base. Mark issues with this. beginner-medium Less than two weeks of work for a beginner. labels Sep 11, 2019
@skyzh
Copy link
Member

skyzh commented Sep 16, 2022

I think it's time to reduce our type to varchar + integer (maybe decimal, float).

unknowntpo added a commit to unknowntpo/bustub that referenced this issue Jun 16, 2023
FIXME: LRUReplacerTest still failed by AddressSanitizer:DEADLYSIGNAL.

$ ctest -R 'LRUReplacerTest' --output-on-failure
Test project /Users/unknowntpo/repo/unknowntpo/bustub/build
    Start 31: LRUReplacerTest.SampleTest
1/1 Test cmu-db#31: LRUReplacerTest.SampleTest .......Subprocess aborted***Exception:   0.18 sec
Running main() from gmock_main.cc
Note: Google Test filter = LRUReplacerTest.SampleTest
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from LRUReplacerTest
[ RUN      ] LRUReplacerTest.SampleTest
2023-06-16 16:00:47 [lru_replacer.cpp:59:Unpin] INFO  - hello
2023-06-16 16:00:47 [lru_replacer.cpp:72:Unpin] INFO  - Unpin is called for frame_id: 1
2023-06-16 16:00:47 [lru_replacer.cpp:59:Unpin] INFO  - hello
2023-06-16 16:00:47 [lru_replacer.cpp:72:Unpin] INFO  - Unpin is called for frame_id: 2
2023-06-16 16:00:47 [lru_replacer.cpp:59:Unpin] INFO  - hello
2023-06-16 16:00:47 [lru_replacer.cpp:72:Unpin] INFO  - Unpin is called for frame_id: 3
2023-06-16 16:00:47 [lru_replacer.cpp:59:Unpin] INFO  - hello
2023-06-16 16:00:47 [lru_replacer.cpp:72:Unpin] INFO  - Unpin is called for frame_id: 4
2023-06-16 16:00:47 [lru_replacer.cpp:59:Unpin] INFO  - hello
2023-06-16 16:00:47 [lru_replacer.cpp:72:Unpin] INFO  - Unpin is called for frame_id: 5
2023-06-16 16:00:47 [lru_replacer.cpp:59:Unpin] INFO  - hello
2023-06-16 16:00:47 [lru_replacer.cpp:72:Unpin] INFO  - Unpin is called for frame_id: 6
2023-06-16 16:00:47 [lru_replacer.cpp:59:Unpin] INFO  - hello
2023-06-16 16:00:47 [lru_replacer.cpp:72:Unpin] INFO  - Unpin is called for frame_id: 1
2023-06-16 16:00:47 [lru_replacer.cpp:39:Victim] INFO  - iter_count: 0
2023-06-16 16:00:47 [lru_replacer.cpp:39:Victim] INFO  - iter_count: 0
2023-06-16 16:00:47 [lru_replacer.cpp:39:Victim] INFO  - iter_count: 0
2023-06-16 16:00:47 [lru_replacer.cpp:48:Pin] INFO  - Pin is called for frame_id: 3
2023-06-16 16:00:47 [lru_replacer.cpp:55:Pin] WARN  - Pin is called with non-exist frame_id: 3
2023-06-16 16:00:47 [lru_replacer.cpp:48:Pin] INFO  - Pin is called for frame_id: 4
AddressSanitizer:DEADLYSIGNAL
=================================================================
==79229==ERROR: AddressSanitizer: SEGV on unknown address 0x00000104f02c (pc 0x000102816328 bp 0x00016d5f8fd0 sp 0x00016d5f8b80 T0)
==79229==The signal is caused by a UNKNOWN memory access.
    #0 0x102816328 in std::__1::pair<std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<int, std::__1::__list_iterator<bustub::node, void*> >, void*>*>, bool> std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::__list_iterator<bustub::node, void*> >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::__list_iterator<bustub::node, void*> >, std::__1::hash<int>, std::__1::equal_to<int>, true>, std::__1::__unordered_map_equal<int, std::__1::__hash_value_type<int, std::__1::__list_iterator<bustub::node, void*> >, std::__1::equal_to<int>, std::__1::hash<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::__list_iterator<bustub::node, void*> > > >::__emplace_unique_key_args<int, std::__1::piecewise_construct_t const&, std::__1::tuple<int const&>, std::__1::tuple<> >(int const&, std::__1::piecewise_construct_t const&, std::__1::tuple<int const&>&&, std::__1::tuple<>&&) __hash_table:2083
    cmu-db#1 0x10280f548 in std::__1::unordered_map<int, std::__1::__list_iterator<bustub::node, void*>, std::__1::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<int const, std::__1::__list_iterator<bustub::node, void*> > > >::operator[](int const&) unordered_map:1743
    cmu-db#2 0x10280ec04 in bustub::LRUReplacer::Pin(int) lru_replacer.cpp:53
    cmu-db#3 0x102806af0 in bustub::LRUReplacerTest_SampleTest_Test::TestBody() lru_replacer_test.cpp:47
    cmu-db#4 0x102863f3c in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) gtest.cc:2657
    cmu-db#5 0x102863810 in testing::Test::Run() gtest.cc:2674
    cmu-db#6 0x1028660b0 in testing::TestInfo::Run() gtest.cc:2853
    cmu-db#7 0x102869044 in testing::TestSuite::Run() gtest.cc:3012
    cmu-db#8 0x10288d304 in testing::internal::UnitTestImpl::RunAllTests() gtest.cc:5870
    cmu-db#9 0x10288c6e4 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) gtest.cc:2657
    cmu-db#10 0x10288bed4 in testing::UnitTest::Run() gtest.cc:5444
    cmu-db#11 0x102929cd0 in RUN_ALL_TESTS() gtest.h:2293
    cmu-db#12 0x102929c2c in main gmock_main.cc:70
    cmu-db#13 0x1a564be4c  (<unknown module>)

==79229==Register values:
 x[0] = 0x0000000104c016c1   x[1] = 0x0000000000000004   x[2] = 0x000000010298dcc0   x[3] = 0x000000016d5f9020
 x[4] = 0x000000016d5f9040   x[5] = 0x000000016d5f9160   x[6] = 0x000000016d5f93b0   x[7] = 0x0000000000002900
 x[8] = 0xc00000000104f02c   x[9] = 0xc00000000104f02c  x[10] = 0x0000000000000001  x[11] = 0x000000702dadf178
x[12] = 0x000000016d5f8b88  x[13] = 0x000000016d5f8b80  x[14] = 0x000000016d5f8e20  x[15] = 0x0000000000000000
x[16] = 0x000000010280f380  x[17] = 0x000000010302c5d0  x[18] = 0x0000000000000000  x[19] = 0x000000016d5f8c80
x[20] = 0x0000000102929aa0  x[21] = 0x0000000102bedc60  x[22] = 0x000000016d5fb050  x[23] = 0x00000001a56c1000
x[24] = 0x00000002011e3340  x[25] = 0x0000000000000000  x[26] = 0x0000000000000000  x[27] = 0x0000000000000000
x[28] = 0x0000000000000000     fp = 0x000000016d5f8fd0     lr = 0x00000001028162b8     sp = 0x000000016d5f8b80
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV __hash_table:2083 in std::__1::pair<std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<int, std::__1::__list_iterator<bustub::node, void*> >, void*>*>, bool> std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::__list_iterator<bustub::node, void*> >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::__list_iterator<bustub::node, void*> >, std::__1::hash<int>, std::__1::equal_to<int>, true>, std::__1::__unordered_map_equal<int, std::__1::__hash_value_type<int, std::__1::__list_iterator<bustub::node, void*> >, std::__1::equal_to<int>, std::__1::hash<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::__list_iterator<bustub::node, void*> > > >::__emplace_unique_key_args<int, std::__1::piecewise_construct_t const&, std::__1::tuple<int const&>, std::__1::tuple<> >(int const&, std::__1::piecewise_construct_t const&, std::__1::tuple<int const&>&&, std::__1::tuple<>&&)
==79229==ABORTING

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.20 sec

The following tests FAILED:
	 31 - LRUReplacerTest.SampleTest (Subprocess aborted)
Errors while running CTest
unknowntpo added a commit to unknowntpo/bustub that referenced this issue Jul 20, 2023
FIXME: Why buffer overflow

Test project /Users/unknowntpo/repo/unknowntpo/bustub/build
    Start 30: LRUKReplacerTest.SampleTest
1/1 Test cmu-db#30: LRUKReplacerTest.SampleTest ......Subprocess aborted***Exception:   0.19 sec
Running main() from gmock_main.cc
Note: Google Test filter = LRUKReplacerTest.SampleTest
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from LRUKReplacerTest
[ RUN      ] LRUKReplacerTest.SampleTest
2023-07-20 09:40:59 [lru_k_replacer.cpp:61:RecordAccess] INFO  - RecordAccess frame_id: 1
2023-07-20 09:40:59 [lru_k_replacer.cpp:61:RecordAccess] INFO  - RecordAccess frame_id: 2
2023-07-20 09:40:59 [lru_k_replacer.cpp:61:RecordAccess] INFO  - RecordAccess frame_id: 3
2023-07-20 09:40:59 [lru_k_replacer.cpp:61:RecordAccess] INFO  - RecordAccess frame_id: 4
2023-07-20 09:40:59 [lru_k_replacer.cpp:61:RecordAccess] INFO  - RecordAccess frame_id: 5
2023-07-20 09:40:59 [lru_k_replacer.cpp:61:RecordAccess] INFO  - RecordAccess frame_id: 6
2023-07-20 09:40:59 [lru_k_replacer.cpp:87:SetEvictable] INFO  - SetEvictable frame_id: 1
2023-07-20 09:40:59 [lru_k_replacer.cpp:87:SetEvictable] INFO  - SetEvictable frame_id: 2
2023-07-20 09:40:59 [lru_k_replacer.cpp:87:SetEvictable] INFO  - SetEvictable frame_id: 3
2023-07-20 09:40:59 [lru_k_replacer.cpp:87:SetEvictable] INFO  - SetEvictable frame_id: 4
2023-07-20 09:40:59 [lru_k_replacer.cpp:87:SetEvictable] INFO  - SetEvictable frame_id: 5
2023-07-20 09:40:59 [lru_k_replacer.cpp:87:SetEvictable] INFO  - SetEvictable frame_id: 6
2023-07-20 09:40:59 [lru_k_replacer.cpp:109:Size] INFO  - size is called
2023-07-20 09:40:59 [lru_k_replacer.cpp:61:RecordAccess] INFO  - RecordAccess frame_id: 1
=================================================================
==35330==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x00016d47c450 at pc 0x00010298ece4 bp 0x00016d47bd30 sp 0x00016d47bd28
READ of size 1 at 0x00016d47c450 thread T0
    #0 0x10298ece0 in bustub::LRUKReplacer::Evict(int*) lru_k_replacer.cpp:33
    cmu-db#1 0x1029837dc in bustub::LRUKReplacerTest_SampleTest_Test::TestBody() lru_k_replacer_test.cpp:44
    cmu-db#2 0x1029e7140 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) g
test.cc:2657
    cmu-db#3 0x1029e6a14 in testing::Test::Run() gtest.cc:2674
    cmu-db#4 0x1029e92b4 in testing::TestInfo::Run() gtest.cc:2853
    cmu-db#5 0x1029ec248 in testing::TestSuite::Run() gtest.cc:3012
    cmu-db#6 0x102a10508 in testing::internal::UnitTestImpl::RunAllTests() gtest.cc:5870
    cmu-db#7 0x102a0f8e8 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool
(testing::internal::UnitTestImpl::*)(), char const*) gtest.cc:2657
    cmu-db#8 0x102a0f0d8 in testing::UnitTest::Run() gtest.cc:5444
    cmu-db#9 0x102aaced4 in RUN_ALL_TESTS() gtest.h:2293
    cmu-db#10 0x102aace30 in main gmock_main.cc:70
    cmu-db#11 0x19952be4c  (<unknown module>)

Address 0x00016d47c450 is located in stack of thread T0 at offset 176 in frame
    #0 0x102982d10 in bustub::LRUKReplacerTest_SampleTest_Test::TestBody() lru_k_replacer_test.cpp:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginner Good for newcomers. Mark issues with this. beginner-medium Less than two weeks of work for a beginner. best-practice Style fixes or refactor in the code base. Mark issues with this.
Projects
None yet
Development

No branches or pull requests

2 participants