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

Time::Sleep always returns Time(0, 0) even if it was interrupted by a signal on Linux #44

Closed
1 task done
osrf-migration opened this issue Nov 21, 2018 · 3 comments
Closed
1 task done
Labels
bug Something isn't working

Comments

@osrf-migration
Copy link

Original report (archived issue) by Silvio Traversaro (Bitbucket: traversaro).


Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:

Description

Inspecting the source code, I noticed that the return value of the clock_nanosleep call in the Time::Sleep method ( https://github.com/ignitionrobotics/ign-common/blob/9eb6b15c700cc641e755811c939e2867e6eaf431/src/Time.cc#L213 ) is compared against -1 to check if the sleep was interrupted before the desired elapsed time has passed. However, in Linux docs ( http://man7.org/linux/man-pages/man2/clock_nanosleep.2.html ) it is explicitly stated that the return value is a positive error message. In particular, the corresponding error should be EINTR, that from a quick check on my Ubuntu 18.04 is equal to:

straversaro@iiticublap103:~$ cat   /usr/include/asm-generic/errno-base.h  | grep EINTR
#define	EINTR		 4	/* Interrupted system call */

So, even if clock_nanosleep returns EINTR the return value of the Sleep is always Time(0, 0).

The same problem is afflicting the Gazebo's version of the method.

Steps to Reproduce

I did not attempt to reproduce the issue, but it should be reproducible by having a process sleeping for a long time, waking it with a signal before the wait period ended, and checking the return value of the Sleep method.

Expected behavior:

Inspecting the rest of the code, I thought that the Sleep method was returning the remainder of time still need to pass before the requested time was elapsed, but according to the docs it is supposed to return the "Time actually slept", so I am not really sure about what the actual expected behavior his.

Actual behavior:

See "Steps to Reproduced". I did not actually reproduced the error.

Reproduces how often:

The wrong check is done always, but when the clock_nanosleep is returning 0, the if is working as expected.

Versions

ignition-common, branch gz11

Additional Information

@osrf-migration
Copy link
Author

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


  • set assignee_account_id to "557058:095b1e12-74ed-4e20-b44f-2f0745b616e0"
  • set assignee to "nkoenig (Bitbucket: nkoenig, GitHub: nkoenig)"

@osrf-migration
Copy link
Author

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


See pull request #176

@osrf-migration
Copy link
Author

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


  • changed state from "new" to "resolved"

Merged in issue_44 (pull request #176)

Fix issue #44

Approved-by: Silvio Traversaro [email protected]

→ <<cset c7d0708>>

@osrf-migration osrf-migration added major bug Something isn't working labels Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant