habanero-rice / hclib

A C/C++ task-based programming model for shared memory and distributed parallel computing.
http://habanero-rice.github.io/hclib/
BSD 3-Clause "New" or "Revised" License
71 stars 35 forks source link

Future wait operation does not restore finish scope #27

Closed DaoWen closed 7 years ago

DaoWen commented 7 years ago

The future wait operation currently does not maintain the thread-local state of the current task. Specifically, the current_finish property is not restored after a potential fiber migration in blocking future wait calls. This can result in the wrong finish scope counter being decremented, and often triggers a segfault later in the execution due to broken synchronization.

The following test program demonstates this behavior:

https://github.com/habanero-rice/hclib/blob/8f649248e5a5d1a0e26dfa3097cce7fec31533db/test/cpp/promise/future4.cpp