Skip to content

Data race problem in mp_coro::sync_await ? #5

@raymundhofmann

Description

@raymundhofmann

I tried one example in msvc2022 and had a wrong return value in debug build, while GCC in compiler explorer was fine.

Shouldn't this function

template<awaitable A>
[[nodiscard]] decltype(auto) sync_await(A&& awaitable)

be declared like this

template<awaitable A>
[[nodiscard]] auto sync_await(A&& awaitable)

So no reference can be returned?

Of course, the whole path the return value takes could be reviewed where a reference is ok and where it should be passed by value.

And shouldn't the return value be properly synchronized, as the used std::binary_semaphore not necessarily synchronizes memory where the
return value might reside between threads ?
The x86 an x86-64 does not require memory fencing, but Arm might, I think.

Concurrency is hard and the total lack of warnings, static checks and support form compilers is offending.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions