threading: fix race condition in ecl_unwind

If ecl_unwind is interrupted with another call to ecl_unwind
    before it has decremented env->frs_top, the second call of
    ecl_unwind may stop too early with its unwinding, leading to
    potential segfaults.
This commit is contained in:
Marius Gerbershagen 2018-02-14 22:52:22 +01:00
parent e7838e4b86
commit 8a68a5c225

View file

@ -564,8 +564,10 @@ ecl_unwind(cl_env_ptr env, ecl_frame_ptr fr)
{
env->nlj_fr = fr;
ecl_frame_ptr top = env->frs_top;
while (top != fr && top->frs_val != ECL_PROTECT_TAG)
while (top != fr && top->frs_val != ECL_PROTECT_TAG){
top->frs_val = ECL_DUMMY_TAG;
--top;
}
env->ihs_top = top->frs_ihs;
ecl_bds_unwind(env, top->frs_bds_top_index);
ECL_STACK_SET_INDEX(env, top->frs_sp);