Opened 6 months ago

Closed 5 months ago

#306 closed defect (fixed)

Waituntil relies on RAII-unsound rvalue-to-reference conversion

Reported by: mlbrooks Owned by: lseo
Priority: major Component: libcfa
Version: 1.0 Keywords: waituntil raii rvalue reference dlist
Cc:

Description

Waituntil uses rvalue-to-reference conversion, probably without realizing it. Types that underlie its implementation should be free to use advanced RAII, which does not support (#305) waituntil's rvalue-to-reference conversion case.

A desired linked-list implementation change (not yet in master) causes the return value of timeout to need RAII that present state rvalue-to-reference promotion does not provide.

#include <concurrency/select.hfa>

int main() {
    waituntil( timeout( 1`ns ) ) {}
    return 0;
}

Actual, master: Runs and exits normally

Actual, with desired linked-list change: runtime crash with assertion failure about dlist precondition not met

Expected, with desired linked-list change: Runs and exits normally

Inspecting intermediate code (at master), cfa demo.cfa -CFA -XCFA,-p,-Pbresolver shows (manually pieced together):

typeof(__CFA_select_get_type(timeout(__postfix_func_ns(1)))) & __clause_target_0 =
    timeout(__postfix_func_ns(1));

Note __clause_target_0 is declared here as a reference, while timeout (from select.hfa) has returns select_timeout_node by value. This is the case of #305.

Change History (3)

comment:1 by mlbrooks, 6 months ago

Component: cfa-cclibcfa

comment:2 by lseo, 6 months ago

Owner: set to lseo
Status: newassigned

comment:3 by lseo, 5 months ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.