STM32FreeRTOS memory issues in PIO

Based on this issue: STM32FreeRTOS breaks I2C · Issue #39 · stm32duino/STM32FreeRTOS · GitHub

The preferred way of memory management, a modified newlib causes crashes on realloc() calls.
Other, non-thread safe memory management schemes heap_1 through heap_5 don’t work either.

Based on maintainer’s comment, it seems like STM32FreeRTOS isn’t supported in PIO and I can’t get it to work either.

Looks like its not just realloc(), malloc() causes the same crash.

Here’s a simple test case. Execution will never leave the second delay() because the HAL_IncTick() will stop being called after the malloc().

#include <Arduino.h>
#include <STM32FreeRTOS.h>

#define DBG 6

setup() {
  pinMode(DBG, OUTPUT);

  digitalWrite(DBG, HIGH); delay(100); digitalWrite(DBG, LOW);
  int *a = (int *) malloc(32);
  digitalWrite(DBG, HIGH); delay(100); digitalWrite(DBG, LOW);
  a[0] = 1; // To keep from being optimized out
}

The same code executes without a crash with Arduino IDE.