MPS issue job004098

TitleUse of clock() is not fork-safe
Statusopen
Priorityoptional
Assigned userGareth Rees
OrganizationRavenbrook
DescriptionOn Unix platforms, the standard library function clock returns the CPU usage of the calling process. This means that it is not monotonic for a process that calls fork -- in the child process, the CPU usage, and thus the result of clock, starts again at 0 after the fork. Thus code that assumes that clock is monotonic may fail to work correctly in the child process after a fork.
AnalysisThis affects telemetry (but see job004067), also PolicyShouldCollectWorld (and thus mps_arena_step), and the low-pass filter for the working set size (on branch/2016-03-13/tradeoff-3). Other uses are ok since two clock values are taken and compared with the arena lock held, and so a fork can't happen at these points because of the pthread_atfork call in LockSetup.
How foundautomated_test
EvidenceNone
Created byGareth Rees
Created on2018-07-23 14:17:21
Last modified byGareth Rees
Last modified on2018-07-23 14:17:21
History2018-07-23 GDR Created.