Bird
0
0

You wrote this code:

medium📝 Debug Q14 of 15
FreeRTOS - Debugging and Monitoring
You wrote this code:
int *ptr = NULL;
configASSERT(ptr != NULL);

But the program crashes immediately. What is the most likely cause?
AThe pointer should be NULL to avoid crash
BThe pointer ptr is NULL, so configASSERT() halts the program
CconfigASSERT() syntax is incorrect and causes crash
DconfigASSERT() only works in release builds
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the pointer value and assertion

    ptr is NULL, but configASSERT checks ptr != NULL, which is false.
  2. Step 2: Understand configASSERT() behavior on false condition

    When the condition is false, configASSERT() halts the program immediately, causing the crash.
  3. Final Answer:

    The pointer ptr is NULL, so configASSERT() halts the program -> Option B
  4. Quick Check:

    NULL pointer fails assert halting program = C [OK]
Quick Trick: Crash means assert condition was false, check pointer value [OK]
Common Mistakes:
  • Thinking configASSERT() syntax caused crash
  • Believing NULL pointer is safe here
  • Assuming configASSERT() runs only in release

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes