Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Segmentation faults of thread library when memory is limited #7038
Original bug ID: 7038
As I was testing the ocaml runtime under limited memory, I discovered that the thread library is likely to segfault when there is not enough memory to allocate internal data structures.
Steps to reproduce
In trunk run :
$ ulimit -Sv 100000
The first command will limit the memory of sub-processes of your shell to 100Mb.
I think, at least one comes from this function in systhreads/st_stubs.c
The call to st_mutex_create could fail. One should probably raise Out_of_memory if mutex is still NULL.
static void caml_io_mutex_lock(struct channel *chan)
st_mutex mutex = chan->mutex;
/* #4351: first try to acquire mutex without releasing the master lock */
/* If unsuccessful, block on mutex /
Comment author: @xavierleroy
Reproduced under Linux x86-64. Indeed, there was a problem in caml_io_mutex_lock that is fixed by commit [trunk 906558a].
Now the testsuite "just" hangs on the thread tests in question, because the Out_of_memory exception kills the current thread, and the main thread deadlocks waiting for a condition variable from the killed thread...