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

rcl_difference_times() function 32 bit overflow #204

Closed
kenny-y opened this issue Dec 28, 2017 · 2 comments
Closed

rcl_difference_times() function 32 bit overflow #204

kenny-y opened this issue Dec 28, 2017 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@kenny-y
Copy link

kenny-y commented Dec 28, 2017

rcl_difference_times() function can't process time diff > 2^31

Bug report

Required Info:

  • Operating System:
    • Ubuntu 16.04
  • Installation type:
    • Ardent Apalone
  • Version or commit hash:
    • NA
  • DDS implementation:
    • Default
  • Client library (if applicable):
    • rcl

Steps to reproduce issue

This test case would pass

Start: sec = 1514423496, nanosec = 0
Finish: sec = 1514423498, nanosec = 147483647
64 bit .nanoseconds: (1514423496000000000 - 1514423498147483647)
rcl_difference_times: delta.nanoseconds = 2147483647
Human readable result: { sec: 2, nanosec: 147483647 }

This test case would fail

Start: sec = 1514423496, nanosec = 0
Finish: sec = 1514423498, nanosec = 147483648
64 bit .nanoseconds: (1514423496000000000 - 1514423498147483648)
rcl_difference_times: delta.nanoseconds = -2147483648  // This is the issue
Human readable result: { sec: -2, nanosec: -147483648 }

Expected behavior

that rcl_difference_times() function can process diff > 2 ^ 31 (e.g. 3 seconds or greater)

Actual behavior

32 bit signed integer overflow

Additional information

I found this when I'm writing Node.js bindings to rcl

@wjwwood
Copy link
Member

wjwwood commented Dec 28, 2017

Thanks for pointing it out @kenny-y. A pr with a test for this and a fix would be greatly appreciated. Otherwise we'll get to it as soon as we have time.

@wjwwood wjwwood added bug Something isn't working help wanted Extra attention is needed labels Dec 28, 2017
@kenny-y
Copy link
Author

kenny-y commented Dec 29, 2017

I'll see what I can do after the new year vacation.

@mjcarroll mjcarroll added the in progress Actively being worked on (Kanban column) label Mar 22, 2018
@mjcarroll mjcarroll removed the in progress Actively being worked on (Kanban column) label Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants