pussuw commented on pull request #5731:
URL: https://github.com/apache/incubator-nuttx/pull/5731#issuecomment-1080795149


   Oops, you are also right, the original code is suspicious too, as the first 
thing exception_common does is this:
   
   ```
   exception_common:
   addi sp, sp, -XCPTCONTEXT_SIZE
   ```
   
   I assume the same issue is in the ARM implementation too.
   In this case the new task's address environment is already in use, but sp 
still points to the old task.
   
   This is not an issue with the new S-mode function however:
   riscv_switchcontext:
   
   ```
     /* Save old context to arg[0] */
   
     save_ctx   a0                        /* save context */
   ```
   
   Saving the context does not use stack, and this is why the code works on my 
table.
   
   But indeed, the location for calling group_addrenv() is suspicious, as the 
context switch is done by using the new tasks environment, even though the old 
task's registers are still in use.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to