----- Message d'origine -----
De Scott Wolchok <[email protected]>
Envoyé   jeu. 15 juil. 2010 06:54:57 CEST
À [email protected]
Objet  [Bug 605737] [NEW] /usr/include/poker-eval/enumerate.h incorrectly 
assumes sizeof(int)==sizeof(int*)

> Public bug reported:
> 
> The offending line is line 624:
> 
>     _curElem = (int **) malloc(num_sets * sizeof(int));                       
>            \
> 
> It should read:
> 
>     _curElem = (int **) malloc(num_sets * sizeof(int*));
> \
> 
> because the array being allocated is an array of int*, as shown by the
> cast, not an array of int. On an x86 system, this is probably fine, but
> on amd64, sizeof(int) != sizeof(int*).
> 
> This causes a crash in a program I wrote using python-pypoker-eval to
> evaluate pre-flop odds in Texas Hold'em, but only when more than 2 hands
> are passed to it.
> 
> The program (preflop_matchup.py):
> 
> #!/usr/bin/env python
> 
> import itertools
> import sys
> 
> import pokereval
> 
> def matchup(hands):
>     pok = pokereval.PokerEval()
>     answer = pok.poker_eval(game='holdem',
>                                                     pockets=hands,
>                                                     board=['__', '__', '__', 
>'__', '__'])
>     samples = float(answer['info'][0])
>     for hand, results in zip(hands, answer['eval']):
>         win_pct = results['scoop'] / samples * 100
>         tie_pct = results['tiehi'] / samples * 100
>         print '%s: %f%% to win, %f%% to tie' % (hand, win_pct, tie_pct)
> 
> 
> def grouper(n, iterable, fillvalue=None):
>         "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
>         args = [iter(iterable)] * n
>         return itertools.izip_longest(fillvalue=fillvalue, *args)
> 
> 
> def main(argv):
>     hands = []
>     for item in argv:
>         hand = list(''.join(x) for x in grouper(2, item))
>         if len(hand) != 2:
>             raise Exception('hands must contain two cards of 2 chars each!')
>         hands.append(hand)
>     matchup(hands)
> 
> 
> if __name__ == '__main__':
>     main(sys.argv[1:])
> 
> 
> To reproduce the crash, on an amd64 Ubuntu 10.4 LTS system:
> python preflop_matchup.py 9h9s adjd jc7c
> 
> 
> Correcting the offending line solves the problem. This may already be fixed
> upstream, as the Ubuntu package is 1 revision out of date.
> 
> ** Affects: poker-eval (Ubuntu)
>           Importance: Undecided
>                   Status: New
> 
> -- 
> /usr/include/poker-eval/enumerate.h incorrectly assumes 
> sizeof(int)==sizeof(int*)
> https://bugs.launchpad.net/bugs/605737
> You received this bug notification because you are subscribed to poker-
> eval in ubuntu.

_______________________________________________
Pokersource-users mailing list
[email protected]
https://mail.gna.org/listinfo/pokersource-users

Reply via email to