Area of Improvements

Review your assessments and practice — drill into each subject, then each attempt, then each question.

Back to summary
C Programming · Round 1

Question 4 of 10

Topic: Constants & literalsDifficulty: HardBloom: Analyze
Question

How would you debug a program where a pointer dereference is failing intermittently?

Result
Knowledge
65%
Delivery
60%
Technical relevancy
68%
Technical term match
58%
Your recording
Your transcript

I would print the pointer value before using it. Maybe use gdb to step through. If it's intermittent it's probably uninitialized memory or something getting freed.

Better answer

Reproduce under a memory checker (valgrind, AddressSanitizer) to catch use-after-free, double-free, and uninitialized reads — these explain most intermittent dereference failures. Add asserts on pointer != NULL and on invariants before deref. In gdb, use watchpoints on the pointer's storage to find who mutates it, and check for stack corruption from buffer overruns nearby.

Coverage
Hit 3 of 5
  • Reaches for valgrind / AddressSanitizer
  • Considers uninitialized memory
  • Considers use-after-free
  • Mentions gdb watchpoints or breakpoints
  • Suggests defensive asserts on NULL/invariants
Gaps
  • Did not mention sanitizers as the first-line tool
  • Skipped stack corruption from adjacent buffer overruns
Misconceptions

None detected.