Skip to content

Fix SH2A_FPU FPU context cleanup#1444

Open
Old-Ding wants to merge 1 commit into
FreeRTOS:mainfrom
Old-Ding:codex/fix-sh2a-fpu-context-cleanup
Open

Fix SH2A_FPU FPU context cleanup#1444
Old-Ding wants to merge 1 commit into
FreeRTOS:mainfrom
Old-Ding:codex/fix-sh2a-fpu-context-cleanup

Conversation

@Old-Ding

@Old-Ding Old-Ding commented Jul 4, 2026

Copy link
Copy Markdown

Summary

  • Add portCLEAN_UP_TCB for the Renesas SH2A_FPU port so task deletion releases the FPU context buffer stored through pxTaskTag.
  • Make xPortUsesFloatingPoint() idempotent when the task already has an FPU buffer, avoiding an immediate leak on repeated calls.
  • Move the FPU buffer sizing macros to portmacro.h so port.c and the cleanup macro use the same constants.

Root cause

xPortUsesFloatingPoint() allocates the FPU context buffer and stores a pointer just past the allocation in pxTaskTag, because the save routine uses a pre-decrement. The port did not define portCLEAN_UP_TCB, so prvDeleteTCB() used the default no-op cleanup and the allocation became unreachable when the task was deleted.

Fixes #1443

Validation

  • git diff --check
  • rg confirmed the FPU buffer constants and portCLEAN_UP_TCB override are scoped to portable/Renesas/SH2A_FPU, with prvDeleteTCB() calling portCLEAN_UP_TCB( pxTCB ) before freeing the TCB/stack.
  • Renesas SH toolchain/hardware build not run locally; no shc, ccsh, sh-elf-gcc, sh-none-elf-gcc, rx-elf-gcc, or ccrx command was found on this machine.

@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

@Old-Ding Old-Ding changed the title [codex] Fix SH2A_FPU FPU context cleanup Fix SH2A_FPU FPU context cleanup Jul 4, 2026
@Old-Ding Old-Ding marked this pull request as ready for review July 4, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Renesas SH2A_FPU port: FPU context buffer leaked on task deletion (no portCLEAN_UP_TCB)

2 participants