Subj : Re: experimental smr-based 100% lock-free eventcount schema for windows... To : comp.programming.threads From : SenderX Date : Wed Feb 02 2005 01:01 am Another bug that will cause a waitset memory leak: > DWORD ac_event_count_wait > ( ac_event_count_t *_this, > DWORD ec_cmp, > DWORD timeout ) > { > int dtor = 0; ^^^^^^^^^^^^^^^^^^^^^^ change to: ac_waitset_t *dtor = 0; > DWORD wait_ret = WAIT_OBJECT_0; > register ac_event_count_t cmp, xchg; > regitser ac_waitset_t *local_waitset = 0; > void **hazard = ac_lfgc_get_hazard( 1 ); [...] > if ( xchg.cmp == ec_cmp ) > { > InterlockedIncrement > ( &xchg.active_waitset->refs ); > > wait_ret = WaitForSingleObject > ( &xchg.active_waitset->queue ); > > if ( ! InterlockedDecrement > ( &xchg->active_waitset->refs ) ) > { > if ( ! InterlockedExchange > ( &xchg->active_waitset->dtor, > 1 ) ) > { > xchg.active_waitset = 0; ^^^^^^^^^^^^^^^^^^^^^^ change to: dtor = xchg.active_waitset; xchg.active_waitset = 0; > > np_ac_atomic_dwcas_rel > ( _this, > &cmp, > &xchg ); > > dtor = 1; ^^^^^^^^^^^^^^^^^^^ remove. > } > } > > *hazard = 0; > > if ( dtor ) > { > ac_lfgc_collect > ( xchg->active_waitset, ^^^^^^^^^^^^^^^^^^^^^^^^ change to: ( dtor, > ac_waitset_dtor ); > } > } > > return wait_ret; > } .