Learn C++ Online

Tools for testing and debugging memory issues (part 1)

On this page
This lesson contains approximately 35 minutes of video content.

Memory safety

Toolchain

AddressSanitizer (ASan)

Clang-14 and debugging symbols

When compiling by hand, you'd include -g to have the compiler write debugging symbols. For the version of clang++ that we're using (v. 14.0.5), DWARFv5 debug format is used by default. Unfortunately, some of our tools will not properly read the DWARF5 generated by clang-14. Therefore, instead of using the -g flag, use -gdwarf-4.

Questions

Q1

QTools for Testing and Debugging Q1

This question is ungraded.

Which of the following statements is incorrect?

Q2

QTools for Testing and Debugging Q2

This question is ungraded.

Given the following code snippet,

char input[6];
std::cin >> input;
std::cout << input << std::endl;

Of the strings below, which is most likely to cause a segmentation fault if read from standard input into input?

Q3

QTools for Testing and Debugging Q3

This question is ungraded.

Of the following statements, three describe programmatic actions/operations that can cause runtime issues, while one is entirely safe. Select the safe statement.