Closed chienchi closed 3 years ago
The code can build and test passed but Sanitizer detect memory leaks. @ollielo @xrfu @cmbiwer @zmgan
Start testing: Mar 26 17:51 MDT
----------------------------------------------------------
1/4 Testing: token
1/4 Test: token
Command: "/home/osboxes/CLionProjects/cppLox/build/tests/c++/token"
Directory: /home/osboxes/CLionProjects/cppLox/build/tests/c++
"token" start time: Mar 26 17:51 MDT
Output:
----------------------------------------------------------
===============================================================================
All tests passed (5 assertions in 1 test case)
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"token" end time: Mar 26 17:51 MDT
"token" time elapsed: 00:00:00
----------------------------------------------------------
2/4 Testing: value
2/4 Test: value
Command: "/home/osboxes/CLionProjects/cppLox/build/tests/c++/value"
Directory: /home/osboxes/CLionProjects/cppLox/build/tests/c++
"value" start time: Mar 26 17:51 MDT
Output:
----------------------------------------------------------
===============================================================================
All tests passed (12 assertions in 1 test case)
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"value" end time: Mar 26 17:51 MDT
"value" time elapsed: 00:00:00
----------------------------------------------------------
3/4 Testing: scanner
3/4 Test: scanner
Command: "/home/osboxes/CLionProjects/cppLox/build/tests/c++/scanner"
Directory: /home/osboxes/CLionProjects/cppLox/build/tests/c++
"scanner" start time: Mar 26 17:51 MDT
Output:
----------------------------------------------------------
token: 1 VAR var var
token: 1 IDENTIFIER language language
token: 1 EQUAL = =
token: 1 STRING lox lox
===============================================================================
All tests passed (4 assertions in 1 test case)
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"scanner" end time: Mar 26 17:51 MDT
"scanner" time elapsed: 00:00:00
----------------------------------------------------------
4/4 Testing: parser
4/4 Test: parser
Command: "/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser"
Directory: /home/osboxes/CLionProjects/cppLox/build/tests/c++
"parser" start time: Mar 26 17:51 MDT
Output:
----------------------------------------------------------
===============================================================================
All tests passed (2 assertions in 1 test case)
=================================================================
==14045==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x7f61d85963a7 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xb03a7)
#1 0x55b714849e6e in Parser::parse() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0xdde6e)
#2 0x55b714847c6c in ____C_A_T_C_H____T_E_S_T____0 /home/osboxes/CLionProjects/cppLox/tests/c++/parser.cpp:43
#3 0x55b7147c1f58 in Catch::FreeFunctionTestCase::invoke() const (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x55f58)
#4 0x55b71478b713 in Catch::TestCase::invoke() const /usr/include/catch.hpp:8341
#5 0x55b7147bf11c in Catch::RunContext::invokeActiveTestCase() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x5311c)
#6 0x55b7147bea14 in Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x52a14)
#7 0x55b7147bb6f1 in Catch::RunContext::runTest(Catch::TestCase const&) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x4f6f1)
#8 0x55b714784cee in Catch::runTests(Catch::Ptr<Catch::Config> const&) /usr/include/catch.hpp:7014
#9 0x55b7147c0f29 in Catch::Session::runInternal() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x54f29)
#10 0x55b7147c0a67 in Catch::Session::run() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x54a67)
#11 0x55b7147c09d3 in Catch::Session::run(int, char const* const*) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x549d3)
#12 0x55b71479a126 in main /usr/include/catch.hpp:11390
#13 0x7f61d7b2ab96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
Direct leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x7f61d85963a7 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xb03a7)
#1 0x55b714849af5 in Parser::literal() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0xddaf5)
#2 0x55b714849d9f in Parser::parse() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0xddd9f)
#3 0x55b7148472f5 in ____C_A_T_C_H____T_E_S_T____0 /home/osboxes/CLionProjects/cppLox/tests/c++/parser.cpp:19
#4 0x55b7147c1f58 in Catch::FreeFunctionTestCase::invoke() const (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x55f58)
#5 0x55b71478b713 in Catch::TestCase::invoke() const /usr/include/catch.hpp:8341
#6 0x55b7147bf11c in Catch::RunContext::invokeActiveTestCase() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x5311c)
#7 0x55b7147bea14 in Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x52a14)
#8 0x55b7147bb6f1 in Catch::RunContext::runTest(Catch::TestCase const&) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x4f6f1)
#9 0x55b714784cee in Catch::runTests(Catch::Ptr<Catch::Config> const&) /usr/include/catch.hpp:7014
#10 0x55b7147c0f29 in Catch::Session::runInternal() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x54f29)
#11 0x55b7147c0a67 in Catch::Session::run() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x54a67)
#12 0x55b7147c09d3 in Catch::Session::run(int, char const* const*) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x549d3)
#13 0x55b71479a126 in main /usr/include/catch.hpp:11390
#14 0x7f61d7b2ab96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
Indirect leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x7f61d85963a7 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xb03a7)
#1 0x55b714849af5 in Parser::literal() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0xddaf5)
#2 0x55b714849e3d in Parser::parse() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0xdde3d)
#3 0x55b714847c6c in ____C_A_T_C_H____T_E_S_T____0 /home/osboxes/CLionProjects/cppLox/tests/c++/parser.cpp:43
#4 0x55b7147c1f58 in Catch::FreeFunctionTestCase::invoke() const (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x55f58)
#5 0x55b71478b713 in Catch::TestCase::invoke() const /usr/include/catch.hpp:8341
#6 0x55b7147bf11c in Catch::RunContext::invokeActiveTestCase() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x5311c)
#7 0x55b7147bea14 in Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x52a14)
#8 0x55b7147bb6f1 in Catch::RunContext::runTest(Catch::TestCase const&) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x4f6f1)
#9 0x55b714784cee in Catch::runTests(Catch::Ptr<Catch::Config> const&) /usr/include/catch.hpp:7014
#10 0x55b7147c0f29 in Catch::Session::runInternal() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x54f29)
#11 0x55b7147c0a67 in Catch::Session::run() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x54a67)
#12 0x55b7147c09d3 in Catch::Session::run(int, char const* const*) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x549d3)
#13 0x55b71479a126 in main /usr/include/catch.hpp:11390
#14 0x7f61d7b2ab96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
Indirect leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x7f61d85963a7 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xb03a7)
#1 0x55b714849af5 in Parser::literal() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0xddaf5)
#2 0x55b714849d9f in Parser::parse() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0xddd9f)
#3 0x55b714847c6c in ____C_A_T_C_H____T_E_S_T____0 /home/osboxes/CLionProjects/cppLox/tests/c++/parser.cpp:43
#4 0x55b7147c1f58 in Catch::FreeFunctionTestCase::invoke() const (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x55f58)
#5 0x55b71478b713 in Catch::TestCase::invoke() const /usr/include/catch.hpp:8341
#6 0x55b7147bf11c in Catch::RunContext::invokeActiveTestCase() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x5311c)
#7 0x55b7147bea14 in Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x52a14)
#8 0x55b7147bb6f1 in Catch::RunContext::runTest(Catch::TestCase const&) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x4f6f1)
#9 0x55b714784cee in Catch::runTests(Catch::Ptr<Catch::Config> const&) /usr/include/catch.hpp:7014
#10 0x55b7147c0f29 in Catch::Session::runInternal() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x54f29)
#11 0x55b7147c0a67 in Catch::Session::run() (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x54a67)
#12 0x55b7147c09d3 in Catch::Session::run(int, char const* const*) (/home/osboxes/CLionProjects/cppLox/build/tests/c++/parser+0x549d3)
#13 0x55b71479a126 in main /usr/include/catch.hpp:11390
#14 0x7f61d7b2ab96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
SUMMARY: AddressSanitizer: 256 byte(s) leaked in 4 allocation(s).
<end of output>
Test time = 0.04 sec
----------------------------------------------------------
Test Failed.
"parser" end time: Mar 26 17:51 MDT
"parser" time elapsed: 00:00:00
----------------------------------------------------------
End testing: Mar 26 17:51 MDT
This is the tricky part that we will address in the near future. "Ignore" the sanitizer for the moment.
ref: commit b1109472f0f81e6b7f1345827037085079a2bbbd
This will be a skeleton test case for this week. Will need to learn about expression/grammar next time.