future::result*() should assert readiness
Issue #389
resolved
The functions future<T...>::result{,_tuple,_reference}
all carry a precondition of this->ready()
. However, the implementation does not currently assert this trivially checkable property. This allows incorrect programs that call result()
on a non-ready future to silently stray into UB in a DEBUG build, where we can/should produce an explanatory fatal error message instead.
Based on evidence from the user-support forum, this has been a problem for real users in the field, so I'll be addressing it before the next release.
Comments (3)
-
reporter -
reporter - changed status to resolved
Fix issue
#389:future::result*()
should assert readinessAdd the missing assertions
Sample failure output:
////////////////////////////////////////////////////////////////////// UPC++ assertion failure: on process 0 (pcp-d-10) at <redacted>/include/upcxx/future/future1.hpp:147 Called future::result() on a non-ready future, which has undefined behavior. Please call future::wait() instead, which blocks invoking progress until readiness, and then returns the result. Alternatively, use future::then(...) to schedule an asynchronous callback to execute after the future is readied. To have UPC++ freeze during these errors so you can attach a debugger, rerun the program with GASNET_FREEZE_ON_ERROR=1 in the environment. //////////////////////////////////////////////////////////////////////
→ <<cset 8bf1c3474133>>
-
reporter Merge pull request #231 into develop
- assert-preconditions:
Update ChangeLog
persona: Enforce the threadmode=seq restriction on master persona ownership
Add some missing assertions to enforce THREADMODE=seq restrictions
Improve assertions for master persona
diagnostic: Add function name information to fatal errors and asserts
memory kinds: Fix several assertions
VIS: minor tweaks to assertions
misc: add some missing assertions for master persona
rpc(_ff): assert validity of recipient argument
broadcast/reduce_one: Assert valid root rank
Add precondition assertions to {team_id,dist_id}::here()
teams: Assert preconditions on rank translation
Update ChangeLog
Fix issue
#389:future::result*()
should assert readiness Use gasnett_fatalerror_nopos when available
→ <<cset f9f97ce91f67>>
- assert-preconditions:
Update ChangeLog
persona: Enforce the threadmode=seq restriction on master persona ownership
Add some missing assertions to enforce THREADMODE=seq restrictions
Improve assertions for master persona
diagnostic: Add function name information to fatal errors and asserts
memory kinds: Fix several assertions
VIS: minor tweaks to assertions
misc: add some missing assertions for master persona
rpc(_ff): assert validity of recipient argument
broadcast/reduce_one: Assert valid root rank
Add precondition assertions to {team_id,dist_id}::here()
teams: Assert preconditions on rank translation
Update ChangeLog
Fix issue
- Log in to comment
Proposed fix in pull request #231
CC: @Dick Gayler