Page MenuHomePhabricator

Bombarding PHP with signals every 2 milliseconds breaks things
Closed, ResolvedPublic


Test script

(we don't have a separate product/component for LuaSandbox?)

The LuaSandbox PHP extension, when profiling is enabled, will bombard PHP with SIGRT_7 every 2 milliseconds. This tends to randomly break important syscalls as they get constantly interrupted.

For example, if PHP has allocated enough memory that a clone() system call would take more than 2 milliseconds then it will never finish because it will constantly get interrupted. The attached test program illustrates this; if you have a particularly fast machine, you might have to increase the size of the allocated string.

For another example, I noticed that the Scribunto unit tests would randomly die when run using the LuaSandbox engine. That stopped once I fixed this bug. Not entirely conclusive, but suggestive that something in PHP got an unexpected EINTR and decided to kill the process.

If LuaSandbox is compiled with LUASANDBOX_PROFILER_USE_THREAD, this isn't a problem because it uses a different mechanism for the profiling. But if you really want to keep the possibility of using signals, it also seems to work to block the signal (using sigprocmask) whenever in_lua is false.

Version: master
Severity: normal




Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:09 AM
bzimport set Reference to bz43034.

Gerrit change 38354 removes the #ifdef for LUASANDBOX_PROFILER_USE_THREAD, making it always use that code.

I have a different changeset that does the "block the signal whenever in_lua is false", but there's no point uploading that for review if we decide go with the more straightforward fix.

Merged by Tim Starling on the 20th. Is this bug fixed now?