Category
php-in-php · stdlib · bootstrap
Problem
sleep(), usleep(), time_nanosleep(), and time_sleep_until() VM handlers use VmSleepNative — libc sleep(3)/usleep(3)/nanosleep(2) via FFI. With PHP_COMPILER_DISABLE_FFI=1, sleep(0) returns false and usleep(0) is a no-op that does not match Zend's success semantics — breaking rate-limit tests and bootstrap timing probes.
Prefer a compiled PHP busy-wait or monotonic-clock poll (hrtime pure path) for zero/sub-second delays; keep libc FFI as optional fast path.
php-src reference
Repro
PHP_COMPILER_DISABLE_FFI=1 php bin/vm.php -r 'var_dump(sleep(0));'
PHP_COMPILER_DISABLE_FFI=1 php bin/vm.php -r 'usleep(0); echo "ok\n";'
Observed: bool(false) for sleep(0); usleep silent no-op.
Expected: int(0) for sleep(0); usleep(0) completes without error.
Scope
| Path |
Work |
ext/standard/VmSleepNative.php |
VmSleepPure using VmHrtimeNative / compiled poll |
ext/standard/sleep.php, usleep.php, time_nanosleep.php, time_sleep_until.php |
Fallback routing |
| JIT/AOT |
lib/JIT/Builtin/TimeSleepRuntime.php unchanged unless VM parity requires |
Done when
Links
Category
php-in-php·stdlib· bootstrapProblem
sleep(),usleep(),time_nanosleep(), andtime_sleep_until()VM handlers useVmSleepNative— libcsleep(3)/usleep(3)/nanosleep(2)via FFI. WithPHP_COMPILER_DISABLE_FFI=1,sleep(0)returnsfalseandusleep(0)is a no-op that does not match Zend's success semantics — breaking rate-limit tests and bootstrap timing probes.Prefer a compiled PHP busy-wait or monotonic-clock poll (
hrtimepure path) for zero/sub-second delays; keep libc FFI as optional fast path.php-src reference
ext/standard/basic_functions.c—PHP_FUNCTION(sleep),usleep,time_nanosleep,time_sleep_untilRepro
Observed:
bool(false)forsleep(0);usleepsilent no-op.Expected:
int(0)forsleep(0);usleep(0)completes without error.Scope
ext/standard/VmSleepNative.phpVmSleepPureusingVmHrtimeNative/ compiled pollext/standard/sleep.php,usleep.php,time_nanosleep.php,time_sleep_until.phplib/JIT/Builtin/TimeSleepRuntime.phpunchanged unless VM parity requiresDone when
ValueErroravailable()Links