After calling walletlock on the Windows version of bitcoin daemon many times (via command line or json-rpc), this error appears in the debug.log:
N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEEE boost::thread_resource_error
I checked the number of threads belonging to the bitcoind.exe process, and every time walletlock is called, thread count increases by one. Those thread do not die and eventually the no of threads limit is breached and the daemon crashes.