Page MenuHomePhabricator

LuaSandbox timer test fails under reprotest/faketime
Closed, InvalidPublic

Description

As part of the https://reproducible-builds.org/ effort, Debian packages are rebuilt in a environment where things are faked to test reproducibility. LuaSandbox's timer test fails when this happens.

tests/timer.log
---- EXPECTED OUTPUT
Lua usage counted:                              yes (0.1s of %fs)
PHP usage counted:                              yes (0.2s of %fs)
Paused PHP usage counted:                        no (0.0s of %fs)
Unpause works:                                  yes (0.2s of %fs)
Auto-unpause works:                             yes (0.1s of %fs)
Reset limit unpauses:                            no (0.0s of %fs)
Pause overrun prevented:                        yes (0.1s of %fs)
PHP to Lua counted:                             yes (0.1s of %fs)
PHP to paused-PHP counted:                      yes (0.2s of %fs)
PHP to paused-PHP to paused-PHP counted:        yes (0.2s of %fs)
paused-PHP to Lua counted:                      yes (0.1s of %fs)
paused-PHP to PHP counted:                      yes (0.2s of %fs)
paused-PHP to paused-PHP counted:                no (0.0s of %fs)
paused-PHP to paused-PHP to paused-PHP counted:  no (0.0s of %fs)
paused-PHP to PHP to paused-PHP counted:        yes (0.2s of %fs)
---- ACTUAL OUTPUT
Lua usage counted:                              yes (0.1s of 0.1s)
PHP usage counted:                              yes (0.2s of 0.2s)
Paused PHP usage counted:                       Invalid clock_id for clock_gettime: -32962
---- FAILED

On Debian Unstable, I reproduced this by installing the reprotest faketime packages (you might want to skip installing recommends since it pulls in a ton of stuff via diffoscope), and then ran reprotest 'make test' 'logs' in the luasandbox directory (after running phpize/configure).

Searching for the error message lead me to https://github.com/wolfcw/libfaketime/issues/127 but it wasn't obvious to me if this is an issue in libfaketime since it still doesn't appear to work.

Event Timeline

Searching for the error message lead me to https://github.com/wolfcw/libfaketime/issues/127 but it wasn't obvious to me if this is an issue in libfaketime since it still doesn't appear to work.

From the discussion there, that does seem to be the cause. In particular, https://github.com/wolfcw/libfaketime/issues/127#issuecomment-348112631 describes what seems to be going on here.

There's nothing that could be done about this in LuaSandbox, so closing this as Invalid.

BTW, I note that the fix described in https://github.com/wolfcw/libfaketime/issues/127#issuecomment-348295653 seems to be incorrect, and might cause tests to fail in the future. CLOCK_REALTIME is wall time, while the clock returned by pthread_getcpuclockid() is per-thread CPU time. Specifically, the clock returned by pthread_getcpuclockid() is supposed to be the same clock that the specified thread uses for CLOCK_THREAD_CPUTIME_ID, and that's the behavior LuaSandbox requires.