CoinUtils
CoinUtils copied to clipboard
std::bad_alloc in CoinFindDirSeparator() when current working directory doesn't exist
On Linux (and possibly other platforms), when the current directory does not exist, then getcwd()
always fails (and gives errno = ENOENT
), meaning that the function enters an infinite loop trying to allocate larger and larger buffers until size
overflows into a negative number leading to a std::bad_alloc
.
https://github.com/coin-or/CoinUtils/blob/ab8cedf4cf4a163725251666f87276e44f492e81/src/CoinHelperFunctions.hpp#L952-L969
This causes Cbc and many other coin programs to crash on startup since they call CoinFindDirSeparator()
.
I'm not sure why the directory separator needs to be found in this way (and not just use defines to set it to backslash on Windows and forward slash everywhere else).