Tools for Testing and Debugging CS128

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/5

flashcard set

Earn XP

Description and Tags

roar

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

6 Terms

1
New cards

Which of the following statements is incorrect?

A memory leak is problematic because it causes memory usage to balloon while the program is running.

Dereferencing the nullptr results in well-defined behavior.

You should be careful about array bounds when indexing into an array.

You shouldn’t access memory after it has been deallocated since a write might get lost, and a read possibly garbage.

Dereferencing the nullptr results in well-defined behavior.

2
New cards

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?
123

Hello World

Howdy

Texas_A&M_University

Texas_A&M_University

3
New cards

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

After deallocating a dynamically allocated memory, assign the pointer that once pointed to the dynamically allocated object the nullptr.

An off-by-one error while indexing into an array.

Forgetting to return a value in a value-returning function.

Interacting with an uninitialized or otherwise invalid pointer.

After deallocating a dynamically allocated memory, assign the pointer that once pointed to the dynamically allocated object the nullptr.

4
New cards

Which sanitizer is defined to help detect undefined behavior?

Asan

Clang-tidy

UBsan

Valgrind

UBsan

5
New cards

A memcheck tool tells you the following:

Total heap usage: 2 allocs, 1 frees, 72,744 bytes

What is this message reporting?

A memory leak: your program called new twice but invoked delete once.

6
New cards

Your program terminates due to a segmentation fault. You have been working with dynamically allocated objects and fear that you may have attempted member access on the nullptr. Which sanitizer should you employ to investigate your suspicion?

AddressSanitizer (ASan).

Clang-Tidy.

UndefinedBehaviorSanitizer (UBSan).

Valgrind.

AddressSanitizer (ASan).