Using std::printf causes a mutex error?

I keep having this issue with some programs where I would get a mutex error message in the serial output, so for testing I made a new program based on empty-embed-OS. When I leave the main empty like this:

#include "mbed.h"

// main() runs in its own thread in the OS
int main()
{
    while (true) 
    {

    }
}

I get no such error message. But when I call the printf function from the standard mbed.h library like so:

#include "mbed.h"

// main() runs in its own thread in the OS
int main()
{
    printf("\nStarting application...\n");
    
    while (true) 
    {

    }
}

The application just crashes!

++ MbedOS Error Info ++
Error Status: 0x80010133 Code: 307 Module: 1
Error Message: Mutex: 0x0, Parameter error
Location: 0x6053
Error Value: 0x0
Current Thread: main Id: 0x20001AC0 Entry: 0x3B61 StackSize: 0x1000 StackMem: 0x20000540 SP: 0x2007FF54 
For more info, visit: https://mbed.com/s/error?error=0x80010133&tgt=MAX32630FTHR
-- MbedOS Error Info --

Worst of all, this happens only most of the time. I made another program in exactly the same manner and that did work. What could I possibly be doing wrong here? The link in the error tells me nothing of use.