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

Protect against overflow/underflow for integer record types #110

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

AlexanderWells-diamond
Copy link
Collaborator

Long, Bool and MBB record types are now protected from out of range values - .set() will throw an exception, and caput() will fail to store the new value. This means records can no longer be put into invalid values, or suffer from integer overflow/underflow.

Also correct an oversight in get_field_offsets, to properly raise a Python exception when the record type cannot be found.

Closes #66

@codecov
Copy link

codecov bot commented Oct 12, 2022

Codecov Report

Merging #110 (9c19bed) into master (dc4a63f) will decrease coverage by 0.13%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##           master     #110      +/-   ##
==========================================
- Coverage   87.03%   86.90%   -0.14%     
==========================================
  Files          14       14              
  Lines         972      985      +13     
==========================================
+ Hits          846      856      +10     
- Misses        126      129       +3     
Impacted Files Coverage Δ
softioc/device.py 94.67% <85.71%> (-0.93%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link

github-actions bot commented Oct 12, 2022

Unit Test Results

     15 files  ±  0       15 suites  ±0   30m 21s ⏱️ + 2m 3s
   253 tests +  6     246 ✔️ +  5      7 💤 +  1  0 ±0 
3 795 runs  +90  3 330 ✔️ +65  465 💤 +25  0 ±0 

Results for commit 9c19bed. ± Comparison against base commit dc4a63f.

♻️ This comment has been updated with latest results.

@AlexanderWells-diamond
Copy link
Collaborator Author

Thinking about it, in its current form this PR does mean you can no longer signal a boolOut/mbbOut record is in an invalid state by setting an out-of-range number to trigger the "ILLEGAL VALUE" error handling in EPICS. That's related to issue #53. I don't know if this is a significant concern.

Long records restricted to int32 min/max, bool to 0 or 1, mbb to 0-15.
This will cause data validation to occur for caput'd values

Also fix tests (previously we were putting invalid values to bool
records)
Note we have to skip mbbOut record testing, as for some reason cothread
caput succeeds for this record type but not for the others
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No protection against overflow/underflow when setting values
1 participant