You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2026/10/08 12:28:32 UTC
(nuttx) 04/04: arch/mips/jz4780: record the running task on interrupt exit.
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5faf14e41f480230ee5d14a8d3885025894b57e5
Author: Daniel P. Carvalho <da...@gmail.com>
AuthorDate: Sun Oct 4 01:08:08 2026 -0300
arch/mips/jz4780: record the running task on interrupt exit.
jz4780_decodeirq() saves the interrupted context into
g_running_tasks[this_cpu()]->xcp.regs on entry, but nothing updates
g_running_tasks[] after a context switch: every interrupt saves the
context into the Idle task's TCB, and once a task exits (up_exit() sets
the entry to NULL) no context is saved at all and the next context
switch restores stale registers.
Set g_running_tasks[this_cpu()] to this_task() before returning, as
pic32mz_decodeirq() does. This is the same bug that crashed the
PIC32MZ-W1 when the netinit thread exited.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Daniel P. Carvalho <da...@gmail.com>
---
arch/mips/src/jz4780/jz4780_decodeirq.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/mips/src/jz4780/jz4780_decodeirq.c b/arch/mips/src/jz4780/jz4780_decodeirq.c
index 4b26ceaf7c9..feedd978259 100644
--- a/arch/mips/src/jz4780/jz4780_decodeirq.c
+++ b/arch/mips/src/jz4780/jz4780_decodeirq.c
@@ -36,6 +36,7 @@
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
+#include <sched/sched.h>
#include "mips_internal.h"
#include "jz4780_gpio.h"
@@ -151,6 +152,12 @@ uint32_t *jz4780_decodeirq(uint32_t *regs)
regs = up_current_regs();
+ /* Record the task that will run when the interrupt returns. Its state
+ * is saved to its TCB on the next interrupt entry (see above).
+ */
+
+ *running_task = this_task();
+
#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV)
/* Check for a context switch. If a context switch occurred, then
* g_current_regs will have a different value than it did on entry. If an