Title | Use of clock() is not fork-safe |
Status | open |
Priority | optional |
Assigned user | Gareth Rees |
Organization | Ravenbrook |
Description | On 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. |
Analysis | This 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 found | automated_test |
Evidence | None |
Created by | Gareth Rees |
Created on | 2018-07-23 14:17:21 |
Last modified by | Gareth Rees |
Last modified on | 2018-07-23 14:17:21 |
History | 2018-07-23 GDR Created. |