-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
negative datetime::delta exception #155
Comments
On an edgerouter lite (running FreeBSD 11.0-CURRENT (ERL) #0 4cf4c54(master)) I am seeing a lot of the tests fail but nothing related to having a negative time delta (suggesting time travel). Some of the test that fail include:
I may be running a rather old test suite, however. I haven't updated this edgerouter with a newer image in some time. Attached are the complete test suite output and results db file. |
The check to ensure the results of a datetime subtraction are postive is correct, but the error message printed when that happens had the values swapped. Fix this. Addresses part of issue #155.
Good catch on the error message. I'm fixing it but I first need to get the Travis setup back in working order so I can properly validate the fix... (Something has changed in the environment there that's causing builds to fail.) Could you rerun with Thanks |
Bleh. The log file does not provide much insight on the problem. (I wonder why I didn't make that error just an assertion to trigger a core dump, which could be more useful here...) Is the failure deterministic? Have you been able to run the Kyua self-tests alone (those in |
It's not deterministic. Some number of tests run, but I've had failures occur between 30min and 3 hours into the test run. To be honest, I suspect a qemu bug since we can't trigger this anywhere else. I've spotted a couple seemingly unrelated test failures in the kyua engine tests:
Some failures in utils, also probably unrelated (the core dump ones are probably test bugs due to us
|
The check to ensure the results of a datetime subtraction are postive is correct, but the error message printed when that happens had the values swapped. Fix this. Addresses part of issue #155.
Well, the failure of If I provide you with a patch plumbing additional logging for the failure you are experiencing, could you apply it and retest? |
I think either I or @staceyson could get it built for mips. I don't currently have a build environment, but do have a machine that I could set one up on. |
Point me to the patch for this and I can build a mips64 package. |
@staceyson: as a hack to see if there are any other issues, I might try replacing the exception in |
On another note, I've done some testing on our FPGA platform and thus far haven't hit this issue, but have managed to wedge the hardware before completing any runs (I've run quite a lot of tests). |
@brooksdavis I created a version that gives abs() of the difference of the two timestamps. It is available at: https://people.freebsd.org/~sson/mips/packages/ You can install the new package or just kyua into /usr/local/bin. |
Disabling the check seems fair, though I can't remember I also find the failure in Would be good to have the list of failures with the hacked binary. |
With @staceyson's package I'm still seeing seeing these exceptions. I've made very sure that I've installed that one and not another one, but something isn't working. The SHA256 of the package is |
I'm no longer able to trigger this so hopefully it's all fixed where ever the bug was. |
I'm seeing this again with the 0.13,3 package on FreeBSD.
|
After further reflection, the core assumption this exception is asserting is false. |
With this patch applied to the port I get a usable kyua for qemu. It's worth noting that I need the patch to use the results database as well since it contains the backwards timestamps. I chose to make "negative" deltas 1us rather than 0us in case there was code that assumed positive deltas. +--- utils/datetime.cpp.orig
++++ utils/datetime.cpp
+@@ -590,11 +590,12 @@
+ datetime::delta
+ datetime::timestamp::operator-(const datetime::timestamp& other) const
+ {
+- if ((*this) < other) {
+- throw std::runtime_error(
+- F("Cannot subtract %s from %s as it would result in a negative "
+- "datetime::delta, which are not supported") % other % (*this));
+- }
++ /*
++ * XXX-BD: gettimeofday isn't necessicarily monotonic so return the
++ * smallest non-zero delta if time went backwards.
++ */
++ if ((*this) < other)
++ return datetime::delta::from_microseconds(1);
+ return datetime::delta::from_microseconds(to_microseconds() -
+ other.to_microseconds());
+ } I'd like to apply this change to the port. |
Thanks for tracking this down! This change is insufficient, if only because it will break tests, and smells like a hack after all. Let me dig and see why "negative deltas" are claimed to be unsupported and how to make use of the monotonic clock, which would be much better to compute deltas. |
Hey @jmmv, any progress on this yet? |
So... I think the way we are tracking time in Kyua is broken. Time deltas are not going to work with the current timing mechanisms if the underlying time can change, and it can as you discovered. The basic question is: what should happen if the current time changes while Kyua is running? Time deltas should work "as you expect", but what about timestamps? Should the "end time" of the run be allowed to be before the "start time", for example? I had two different thoughts:
There of course is the possibility of ignoring this altogether and truncating the timestamps, as your change proposes, but I fear this will not resolve other problems that may exist. Thoughts? |
The timer creation (setitimer...) should be replaced with timer_create (see #164 for more details). |
Unfortunately, macOS does not have |
@jmmv any of your suggestions would work, and any of them would be much better than crashing, which is what Kyua does now. Personally, I don't think it's a big problem if Kyua thinks a test had a negative duration. It shouldn't happen very often, and the cause will be fairly obvious. The best solution is obviously to store both RTC and monotonic times in each timestamp, though it's the most work. I wouldn't worry about database compatibility issues too much. Most people only care about the most recent run, and I would think that most people who do keep historical data keep it in the form of the junit.xml files. |
We're well past the first anniversary of this bug without progress so I plan to commit my hack which makes negative deltas positive 1ms as a patch to the port to allow us to start testing MIPS in ci.freebsd.org and to let me stop rolling my own package in the CheriBSD project. |
Please go ahead with that plan. I've only recently retaken Kyua-related work after finding a way to fit it into my schedule, and there are many things to go through... :-/ |
Thanks! |
As reported in freebsd/kyua#155, the wall clock time can go backwards resulting in an apparent negative delta. As a workaround, convert such deltas to 1us. This allows tests to run successfully in MIPS64 qemu. Approved by: jmmv (maintainer) Sponsored by: DARPA, AFRL git-svn-id: svn+ssh://svn.freebsd.org/ports/head@436312 35697150-7ecd-e111-bb59-0022644237b5
As reported in freebsd/kyua#155, the wall clock time can go backwards resulting in an apparent negative delta. As a workaround, convert such deltas to 1us. This allows tests to run successfully in MIPS64 qemu. Approved by: jmmv (maintainer) Sponsored by: DARPA, AFRL
The computer's concept of "now" can go backwards (and does so with regularity in QEMU MIPS). If two timestamps are mis-ordered, just return a 1ms delta. For more discussion of this issue see: freebsd#155
The computer's concept of "now" can go backwards (and does so with regularity in QEMU MIPS). If two timestamps are mis-ordered, just return a 1ms delta. See also: freebsd#155 Test fix sumitted by: @ngie-eign
The computer's concept of "now" can go backwards (and does so with regularity in QEMU MIPS). If two timestamps are mis-ordered, just return a 1ms delta. See also: freebsd#155 Test fix sumitted by: @ngie-eign
I've started trying to run the FreeBSD test suite on mips64 under qemu. The run inevitably fails (after an indeterminate number of tests) with:
The check in
datetime::timestamp::operator-
appears to be correct, but the exception string has the variables swapped.I'm using the
kyua-0.12,2
package. The version of qemu is the amd64 version ofemulators/qemu-cheri
. I can provide images if that would be useful. I'll try to get this tested on real hardware as well to try and rule out a qemu bug.The text was updated successfully, but these errors were encountered: