A bug in STM32 bareboard runtimes

Hi! A month ago I found a bug in STM32 tasking runtime (such as light-tasking-stm32f429disco) that causes hangs. I reported upstream, but it’s not fixed yet and the latest gcc 15 cross in Alire still has it. I write about it here and propose a patch just in case if people need it. I’m unable to write a reproducer however.

In short: System.BB.Threads.Queues contains structures that are not designed for concurrent modification from multiple threads, but this occurs during the processing of nested interrupts.

the patch is:

diff -Naur light-tasking-stm32f429disco/gnarl/s-bbinte.adb light-tasking-stm32f429disco/gnarl/s-bbinte.adb
--- light-tasking-stm32f429disco/gnarl/s-bbinte.adb	2025-05-20 13:58:06.159520240 +0300
+++ light-tasking-stm32f429disco/gnarl/s-bbinte.adb	2025-05-20 13:58:50.923135620 +0300
@@ -179,6 +179,7 @@
 
       --  Store the interrupt being handled
 
+      CPU_Primitives.Disable_Interrupts;
       Interrupt_Being_Handled (CPU_Id) := Id;
 
       --  Then, we must set the appropriate software priority corresponding
5 Likes