-
Notifications
You must be signed in to change notification settings - Fork 58
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
32bit overflow does not work #125
Comments
read later comment
is true if (now > node->t) (taking overflow semantic into account) |
I did a bit of testing using https://godbolt.org/z/qKPeoazhr overflow seems to be applied when the whole calculation is done -> calculate an offset
add offset to difference then cast to _t and compare to offset
(this works as well if for any reason clock_time_t would be signed) |
Prints
I'm not sure, why |
OK, it's not that simple as in java ;-). |
should be used
since the later might lead into UB since singed overflow is not defined and might not work as expected if optimized and the compiler chose to do the substraction and the comparison on an larger type. the c off all loops is expected to equal the number of loops (300) or 0 (if TN_OFFSET if defined negative)
|
Fixes issue: eclipse#125 Signed-off-by: Achim Kraus <achim.kraus@bosch.io>
Fixes issue: eclipse#125 Signed-off-by: Achim Kraus <achim.kraus@bosch.io>
Fixes issue: eclipse#125 Signed-off-by: Achim Kraus <achim.kraus@bosch.io>
Fixes issue: eclipse#125 Signed-off-by: Achim Kraus <achim.kraus@bosch.io>
Fixes issue: eclipse#125 Signed-off-by: Achim Kraus <achim.kraus@bosch.io>
Hi @obgm: since @boaks detected this issue though reading the code, I described it, @boaks developed the fixing PR (hence he solver what he read by writing) and I gave my cent to it (correct overflow handling regardless of singnedness). |
I think, adding some unit test for the calculation may be an idea. But for now, there is too much other stuff already pending. |
@kfessel sorry for the confusion |
dtls_time.h seems to be uint32_t aware:
tinydtls/dtls_time.h
Line 64 in 68b2521
but these lines may produce problems with 32bit overflow:
these calculate possibly overflowing time stamps:
tinydtls/dtls.c
Line 1763 in 68b2521
tinydtls/dtls.c
Line 4534 in 68b2521
these do not deal with overflowing timestamps:
calculating if the timeout happend: (timestamp passed by)
tinydtls/dtls.c
Line 4596 in 68b2521
inserting (sorted) into the netq
tinydtls/netq.c
Line 96 in 68b2521
In #123 @boaks and me pointed that out
reference / line number are current develop branch
The text was updated successfully, but these errors were encountered: