diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2015-11-08 23:48:32 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2015-11-08 23:48:32 -0800 |
commit | 45dfa2d8640ab94c86ba97d5dc15db87badc67fb (patch) | |
tree | b7b6a4a88c105b7f34c19bdda03fb0a1200f96d6 /src/fish_tests.cpp | |
parent | c2024a6a948f3669f611d9830c1559fb2979c3ea (diff) |
Attempt to fix the sporadic uvar test failures on Linux
We identify when the universal variable file has changed out from under us by
comparing a bunch of fields from its stat: inode, device, size, high-precision
timestamp, generation. Linux aggressively reuses inodes, and the size may be
the same by coincidence (which is the case in the tests). Also, Linux
officially has nanosecond precision, but in practice it seems to only uses
millisecond precision for storing mtimes. Thus if there are three or more
updates within a millisecond, every field we check may be the same, and we are
vulnerable to the ABA problem. I believe this explains the occasional test
failures.
The solution is to manually set the nanosecond field of the mtime timestamp to
something unlikely to be duplicated, like a random number, or better yet, the
current time (with nanosecond precision). This is more in the spirit of the
timestamp, and it means we're around a million times less likely to collide.
This seems to fix the tests.
Diffstat (limited to 'src/fish_tests.cpp')
-rw-r--r-- | src/fish_tests.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index cef1857f..41a0a90f 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -2563,7 +2563,7 @@ static int test_universal_helper(int *x) bool synced = uvars.sync(NULL); if (! synced) { - err(L"Failed to sync universal variables"); + err(L"Failed to sync universal variables after modification"); } fputc('.', stderr); } @@ -2573,7 +2573,7 @@ static int test_universal_helper(int *x) bool synced = uvars.sync(NULL); if (! synced) { - err(L"Failed to sync universal variables"); + err(L"Failed to sync universal variables after deletion"); } fputc('.', stderr); |