Defensive programming to be sure getcwd exists!

In rare circumstances, we're hitting an assertion inside LLVM that can
only happen if a call to getcwd() fails. This stupid bit of code is to
try to catch it in the act and figure out exactly what's going
wrong. Should not bother anybody not at SPI.