[galib] Bug in deterministic and stochastic remainder samling selectors ?
gio sarto
teofilo68 at yahoo.co.uk
Fri Aug 13 07:30:16 EDT 2004
Dear all
I think I found a bug in both
GADSSelector
GASRSSelector
because my test program crashes every now and then
with SEGV or signal 11 error under lunux and g++
2.8.5.
The problem is in the source file GASelector.C,
in the while loops like:
while(ne > 0){
choices[k] = i;
k++; ne--;
}
that start respectively at lines:
301 and 341 of GASRSSelector::update()
and
433 and 469 of GADSSelector::update().
In those loops there is no check that k < pop.size(),
and sure enough it often happens that the choices[]
array is written out of bounds, with consequent memory
corruption.
I propose the following fix,
replace the while statements above:
while(ne > 0)
with
while((ne > 0) && (k < n))
as far as I understand it does not affect the logic
of the selection but fixes the bug.
I will be glad to ear your comments.
Cheers
Giovanni Sartoni
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
More information about the galib
mailing list