diff options
authorSandrine Bailleux <sandrine.bailleux@arm.com>2019-01-18 13:30:29 +0100
committerSandrine Bailleux <sandrine.bailleux@arm.com>2019-01-18 14:32:47 +0100
commit971545c399ec0e79718132bcf7883111842b76e8 (patch)
parenta2d516fc5215973b4df38fe072fb68a8899e4ae4 (diff)
Use lock-less printf() in assert macro
This allows to use assertions in interrupt context (which we do in some places currently). Before this patch, a CPU could dead lock itself by: 1. acquiring the printf lock in the normal execution context; 2. taking an interrupt while still holding the lock; 3. inside the interrupt handler, executing an assertion check that fails and thus tries to print an error message on the UART. In a situation where several CPUs might be executing assert() at the same time, we will now get interleaved messages but that should be pretty rare. Change-Id: I6d1603300f6a3ea5756a46338cb950b7ca3e7956 Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/stdlib/assert.c b/lib/stdlib/assert.c
index 39f30d12..4b53d1e0 100644
--- a/lib/stdlib/assert.c
+++ b/lib/stdlib/assert.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
-#include <debug.h>
+#include <stdio.h>
* This is a basic implementation. This could be improved.
@@ -12,6 +12,8 @@
void __assert (const char *function, const char *file, unsigned int line,
const char *assertion)
- mp_printf("ASSERT: %s <%d> : %s\n", function, line, assertion);
- while (1);
+ printf("ASSERT: %s <%d> : %s\n", function, line, assertion);
+ while (1)
+ ;