Skip to content
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

faster_than_clock.c++ test fail on Windows #74

Open
bitshifter opened this issue Sep 12, 2016 · 7 comments
Open

faster_than_clock.c++ test fail on Windows #74

bitshifter opened this issue Sep 12, 2016 · 7 comments

Comments

@bitshifter
Copy link

test/faster_than_clock.c++:22: FAILED:
due to unexpected exception with message:
  could not measure benchmark, maybe it was optimized away

This test is failing for me when compiled with msvc2015 and mingw64 g++. I've tried it on multiple machines. It seems to be OS specific rather than compiler or hardware.

@rmartinho
Copy link
Collaborator

rmartinho commented Sep 14, 2016

That is very strange, as the test uses a fake clock. Maybe this is not propagated properly across calls :|

@rmartinho
Copy link
Collaborator

Right, figured that out. However, that this failed on Windows specifically means that I can use it to reproduce another bug I've seen before. I'll have a usable Windows machine soon and I'll look into this.

rmartinho added a commit to rmartinho/nonius that referenced this issue Sep 14, 2016
Now only nonius::go has a defaulted Clock parameter. This addresses libnonius#74
by fixing the test, but it doesn't address the underlying problem that
occurs with the default_clock.
@bitshifter
Copy link
Author

I also reproduced it on Windows running in a VM on Linux if that's any help.

@bitshifter
Copy link
Author

The test still seems to be failing on Windows with changes in ddddadf.

@bitshifter
Copy link
Author

I've done some investigation into this. I think the problem is uninitialized variables on execution_plan. In particular the warmup_time member which is of type std::chrono::nanonseconds. If I print that out before the test runs it's different every time. It seems like there's no sensible default constructor being generated for execution_plan's duration values, if I add one like this:

execution_plan() : iterations_per_sample{}, estimated_duration{}, warmup_time{}, warmup_iterations{} {}

then the test starts passing.

I can understand the int values not being initialized, but the duration values look like they should have a default constructor - although I'm not sure what value the default should be initialized to.

@bitshifter
Copy link
Author

bitshifter commented Sep 22, 2016

OK, looking at the documentation on MSDN this is expected behaviour - the default constructed value is uninitialized - https://msdn.microsoft.com/en-us/library/hh874737.aspx?f=255&MSPPError=-2147217396

edit: it's strange that this is fine on Linux but not Windows, even when building with mingw64 g++ which has exactly the same chrono header as what I'm using on Linux. I can only assume it's some difference between how executables are linked or run on each platform.

@bitshifter
Copy link
Author

Continuing my novella on this topic; I discovered that these uninitialised variables are reported when I run valgrind ./bin/test on Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants