@Elco, now that is very interesting indeed! Makes sense.
Have you raised a support ticket for your finding as per @ScruffR comments here: WiFi.ready() == FALSE but WiFi is connected - #3 by ScruffR ?
@avtolstoy, any comment on @Elco's statement:
I think the interaction with SPI is that the SPI class uses a recursive os mutex. If there is no free memory, allocation fails, the mutex cannot get a lock and a deadlock occurs.
Re accessing the HAL functions directly, how is this done? I did not think that this could be done from the application. If so, great!