https://bugs.winehq.org/show_bug.cgi?id=55721
--- Comment #1 from François Gouget fgouget@codeweavers.com --- I cannot reliably reproduce this issue. * Using the very script used by my TestBot I had a 50% success rate (out of 2 tries). * But I was never able to reproduce the issue when trying to bisect the issue, even if running all the tests like in the nightly WineTest runs.
The test allocates 16 MB and checks whether that's reflected in the memory returned by NtQueryInformationProcess(ProcessVmCounters). The implementation relies on the VMSize value in /proc/pid/maps. But the documentation says:
| Some of these values are inaccurate because of a kernel- | internal scalability optimization. If accurate values are | required, use /proc/pid/smaps or /proc/pid/smaps_rollup | instead, which are much slower but provide accurate, | detailed information.
I understand this as meaning VmSize may be a bit out-of-date which explains the failure case. But that still does not explain why in some cases it is reliably up-to-date.
Anyway, one fix may be to switch to /proc/pid/smaps as suggested by the documentation. That depends on whether accuracy or performance is more important for this API.
Another may be to just try the call a couple of time to give /proc/pid/maps time to catch up (e.g. using the tryok mechanism).