Fix hang after 8 hours with certain compilers #987
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Per issue #968, some recent compilers get confused by the integer comparison
if ( (txbeg - (now + TX_RAMPUP)) < 0)
comparison which appears inengine_update_inner()
. Apparently, the macro expansion forTX_RAMPUP
(which involves a call tous2osticks()
, which is again a macro) causes the expression to be promoted toint64_t
despite the explicit type casts on the result.Not surprisingly, adding more typecasts doesn't help. What helps is computing
txbeg - (now + TX_RAMPUP))
, assigning the result to avolatile osticks_t
variable, and then checking that.volatile
forces the assignment to actually take effect, andosticks_t
is the 32-bit integral type we want.