Hack server wedges itself on C assert - use a custom assert that raises ocaml exception
Summary:
Hack server wedges itself when a C assert is hit. The server process remains
alive but is no longer checking for client connections being passed down by
the monitor. Also, since the server process is alive, the monitor thinks
everything is normal so doesn't attempt to restart the server.
This was seen in the wild by `assert(hashtbl[slot2].addr == NULL)` in hh_move
failing, causing the server to wedge itself. `hh_client stop` also didn't fix
it since the hung server process isn't accepting the sigusr2 signal either.
C assert is supposed to trigger a sigabrt, which is supposed to terminate
the process. But something here isn't working. I tried installing a sigabrt
signal handler which should catch the sigabrt raised by assert() failure, but
that didn't fix things. I think Ocaml sets up some wonky systems signal
stuff when it flips into C code, but I don't know how to test this preventing
C assert from terminating the program with sigabrt. Normal sigabrt
on the server process works (`kill -6` in a terminal) and the monitor
discovers it as expected. It's just C assert failures that don't.
Fixing this by creating a custom assert macro. I include the file name
and the line number in the failure message, which is preserved in the logs.
Reviewed By: dabek
Differential Revision:
D3761344
fbshipit-source-id:
6bacccda06a944e329e58eda01516037622f7e86