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

equeue: Fix overflow in rtos-less timeout code #7782

Merged
merged 1 commit into from Aug 16, 2018

Conversation

Projects
None yet
6 participants
@geky
Member

geky commented Aug 14, 2018

Description

See #7732

Thanks to @simonnilsson
CC @cmonr, @pan-

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Feature
[ ] Breaking change

@geky geky referenced this pull request Aug 14, 2018

Closed

EventQueue overflow #7732

@@ -154,7 +154,7 @@ bool equeue_sema_wait(equeue_sema_t *s, int ms) {
if (ms == 0) {
return false;
} else if (ms > 0) {
timeout.attach_us(callback(equeue_sema_timeout, s), ms*1000);
timeout.attach_us(callback(equeue_sema_timeout, s), (us_timestamp_t)ms*1000);

This comment has been minimized.

@adbridge

adbridge Aug 14, 2018

Contributor

Shouldn't this be (us_timestamp_t)(ms * 1000) ?

This comment has been minimized.

@pan-

pan- Aug 14, 2018

Member

Why would it be ? result of the expression (ms * 1000) is int which means it is already truncated if it has overflowed.
We want to promote either ms or 1000 to make the calculation happen in the us_timestamp_t number system.

This comment has been minimized.

@adbridge

adbridge Aug 14, 2018

Contributor

True, we can cast ms to us first and then do the multiplication, though I think what i suggested is clearer to the intention but I don't care that much tbh :)

This comment has been minimized.

@pan-

pan- Aug 14, 2018

Member

I must be missing something but what you suggested is very different and produce different result; see here

@adbridge adbridge requested a review from pan- Aug 14, 2018

@pan-

pan- approved these changes Aug 14, 2018

@adbridge adbridge added needs: CI and removed needs: review labels Aug 14, 2018

@adbridge

This comment has been minimized.

Contributor

adbridge commented Aug 14, 2018

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented Aug 14, 2018

@cmonr

This comment has been minimized.

Contributor

cmonr commented Aug 14, 2018

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented Aug 14, 2018

Build : SUCCESS

Build number : 2812
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7782/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@cmonr cmonr added ready for merge and removed needs: CI labels Aug 16, 2018

@cmonr cmonr merged commit 7927823 into master Aug 16, 2018

16 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-mbed2-build build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/branch This commit looks good
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
travis-ci/astyle Passed, 583 files
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/events Passed, runtime is 10184 cycles (-370 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/licence_check Local licence_check testing has passed
Details
travis-ci/littlefs Passed, code size is 9960B (+0.00%)
Details
travis-ci/tools-py2.7 Local tools-py2.7 testing has passed
Details

pan- pushed a commit to pan-/mbed that referenced this pull request Aug 22, 2018

Merge pull request ARMmbed#7782 from ARMmbed/g-equeue-fix-rtos-less-t…
…imeout-overflow

equeue: Fix overflow in rtos-less timeout code

@cmonr cmonr deleted the g-equeue-fix-rtos-less-timeout-overflow branch Sep 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment