-
Notifications
You must be signed in to change notification settings - Fork 417
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
test_time sleep_until_basic_steady sometimes times out on aarch64 #1829
Comments
https://ci.ros2.org/job/ci_linux/15660/console
I'm still not sure why this test only sometimes hangs on aarch64. Maybe the steady clock resolution is a lot higher and the conversion to the system clock experiences overflow? |
Very similar discussion in ros2/ros2#1080 |
The problem seems to be If I synchronize the clocks in if (this_clock_type == RCL_STEADY_TIME) {
// Synchronize because RCL steady clock epoch might differ from chrono::steady_clock epoch
const Time rcl_entry = now();
const std::chrono::steady_clock::time_point chrono_entry = std::chrono::steady_clock::now();
const Duration delta_t = until - rcl_entry;
const std::chrono::steady_clock::time_point chrono_until =
chrono_entry + std::chrono::nanoseconds(delta_t.nanoseconds());
// XXX vvv
#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
std::cerr << "_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT is defined\n";
#else
std::cerr << "_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT is not defined\n";
#endif
#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
std::cerr << "_GLIBCXX_USE_CLOCK_MONOTONIC is defined\n";
#else
std::cerr << "_GLIBCXX_USE_CLOCK_MONOTONIC is not defined\n";
#endif
#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
std::cerr << "_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL is defined\n";
#else
std::cerr << "_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL is not defined\n";
#endif
#ifdef CLOCK_MONOTONIC_RAW
std::cerr << "CLOCK_MONOTONIC_RAW is defined\n";
#else
std::cerr << "CLOCK_MONOTONIC_RAW is not defined\n";
#endif
std::cerr << "Using GCC version " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << "\n";
typedef std::chrono::steady_clock _Clock;
typedef std::chrono::system_clock __clock_t;
const auto __atime = chrono_until;
const typename _Clock::time_point __c_entry = _Clock::now();
const __clock_t::time_point __s_entry = __clock_t::now();
const auto __delta = __atime - __c_entry;
const auto __s_atime = __s_entry + __delta;
std::cerr << "__atime: " << __atime.time_since_epoch().count() << "\n";
std::cerr << "__c_entry: " << __c_entry.time_since_epoch().count() << "\n";
std::cerr << "__s_entry: " << __s_entry.time_since_epoch().count() << "\n";
std::cerr << "__delta: " << __delta.count() << "\n";
std::cerr << "__s_atime: " << __s_atime.time_since_epoch().count() << "\n";
// XXX ^^^
// loop over spurious wakeups but notice shutdown
std::unique_lock lock(impl_->clock_mutex_);
while (now() < until && context->is_valid()) {
cv.wait_until(lock, chrono_until);
}
|
Bug report
Required Info:
Steps to reproduce issue
Expected behavior
The test should always pass
Actual behavior
Sometimes on aarch64 the test
[ RUN ] TestClockSleep.sleep_until_basic_steady
times out.Additional information
Happened on this job: https://ci.ros2.org/view/nightly/job/nightly_linux-aarch64_release/1760/testReport/junit/projectroot.test/rclcpp/test_time/
Probably introduced by #1814
Maybe related to this gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41861
I'd like to figure out if
_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
is set on the aarch64 machines or not. IIUC if that is not defined thencondition_variable
may use the system clock, in which case a time jump of the system clock could cause sleeping on the steady clock to be affected.https://github.com/gcc-mirror/gcc/blob/e1d4359264585acc8210ba60abb6dfb15bf1fa57/libstdc%2B%2B-v3/include/std/condition_variable#L71-L75
Maybe
condition_variable
isn't the thing to use?The text was updated successfully, but these errors were encountered: