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

vxworks osapi.c OS_Milli2Ticks() problems #104

Closed
skliper opened this issue Sep 30, 2019 · 15 comments · Fixed by #603 or #607
Closed

vxworks osapi.c OS_Milli2Ticks() problems #104

skliper opened this issue Sep 30, 2019 · 15 comments · Fixed by #603 or #607
Assignees
Labels
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Sep 30, 2019

Two problems found:

  1. OS_Milli2Ticks() returns type 'int32' from variable declared as 'uint32'.
  2. There are no limit checks on input value. The calculation may generate overflow on the resulting output type.

Identified with #45 white-box coverage testing.

@skliper skliper self-assigned this Sep 30, 2019
@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Imported from trac issue 81. Created by abrown4 on 2015-07-17T14:15:39, last modified: 2019-08-14T14:11:46

@skliper skliper added the bug label Sep 30, 2019
@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by abrown4 on 2015-07-21 14:39:05:

commit: [changeset:67e90ac] Trac #104, fixed OS_Milli2Ticks() out of range bugs.

Improved error detection to eliminate negative values, fixed types, added explicit casts, and added explicit range check.

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by abrown4 on 2015-07-24 17:19:47:

Feedback: Don't use a hardcoded number. Return OS_ERROR instead of an incorrect value.

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by abrown4 on 2015-07-24 18:53:28:

commit: [changeset:0383f17] Trac #104, Fixed osapi.c OS_Milli2Ticks() to return OS_ERROR. Also removed hardcoded number in favor of including limits.h.

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by abrown4 on 2015-08-20 13:37:10:

commit: [changeset:442d759] reverted the above commits after 8/19 code review inspection. The inspection discussion resolved that it would be better to separate the returned ticks and an error code indication. Combining the two ideas into a single return value is too risky for callers to blindly use. All the call sites for OS_Milli2Ticks() need to be tracked down and corrected as well.

This problem remains.

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by jhageman on 2019-02-28 15:16:28:

Please confirm condition still exists, and if so provide estimated work complete date or detail what external inputs are needed to be able to provide a work complete date.

@skliper skliper removed their assignment Sep 30, 2019
@skliper
Copy link
Contributor Author

skliper commented Oct 22, 2019

Neither this function OS_Milli2Ticks or OS_Tick2Micros are great. Worth a review of use cases.

@jphickey
Copy link
Contributor

It is not clear to me why an application (high level task) would need to deal directly with the concept of OS ticks. This should be entirely abstracted by OSAL and the mere presence of a function like this is really pointing to an issue elsewhere, something OSAL isn't sufficiently abstracting.

I would like to see these two functions deprecated.

@skliper skliper added the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Mar 25, 2020
@astrogeco
Copy link
Contributor

CCB 2020-03-25: No objection

@astrogeco astrogeco added CCB - 20200325 and removed CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) labels Mar 25, 2020
@skliper
Copy link
Contributor Author

skliper commented Aug 5, 2020

@tngo67 @ejtimmon - we OK to deprecate OS_Milli2Ticks and OS_Tick2Micros?

@skliper skliper added this to the 5.2.0 milestone Aug 5, 2020
@ejtimmon
Copy link

@tngo67 @ejtimmon - we OK to deprecate OS_Milli2Ticks and OS_Tick2Micros?

No objection from me. The GSFC apps do not use these functions.

@tngo67
Copy link

tngo67 commented Aug 11, 2020

@tngo67 @ejtimmon - we OK to deprecate OS_Milli2Ticks and OS_Tick2Micros?

No issue for us either.

@skliper
Copy link
Contributor Author

skliper commented Aug 11, 2020

Just making OS_Milli2Ticks an internal function doesn't really solve the issues, since it's reachable from several other API's and timeout isn't checked before it's passed in. In at least the case I'm looking at now, timeout is int32 from the API also (OS_QueueGet). Do we add checks to timeout values at the shared layer (>= 0, < whatever the rollover limit would be)?

EDIT - -1 is OK as wait forever... so -1, or >=0 and < rollover value?

@skliper
Copy link
Contributor Author

skliper commented Aug 11, 2020

What to do in a case where the requested value in milliseconds would roll over? Wait up to the maximum number of ticks and timeout? Reject the input as invalid and return immediately?

@skliper skliper added the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Aug 12, 2020
@skliper
Copy link
Contributor Author

skliper commented Aug 12, 2020

CCB 2020-08-12: Return immediately an error and check for error cases internally

@astrogeco astrogeco removed the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Aug 26, 2020
@skliper skliper modified the milestones: 5.2.0, 6.0.0 Sep 1, 2020
@skliper skliper self-assigned this Sep 21, 2020
skliper added a commit to skliper/osal that referenced this issue Sep 22, 2020
- Removed OS_Tick2Micros implementation, tests, stubs, references
- Moved prototype from API to internal for OS_Milli2Ticks
- Updated OS_Milli2Ticks to return status
- Added check for rollover in OS_Milli2Ticks
- OS_Milli2Ticks now sets and limits ticks as int
- Updated all internal use of OS_Milli2Ticks to check for error
  and returns immediately on error (won't wait maximum amount)
- Coverage tests updated to check for new error cases
- OS_Milli2Ticks stub updated (default implementation)
yammajamma added a commit that referenced this issue Sep 24, 2020
Fix #104, Remove OS_Tick2Micros and internalize OS_Milli2Ticks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants