#668 Random number generator infinite loop?


The Complex Random Number generator in z-rand.c near lines 170 seems to have an infinite loop issue.

Forcing the game to use the LCRNG by commenting out this code allows it to work.

The symptoms manifest as a failure in the midst of character generation. Before the autoroller screen plots, the game just goes away forever.

astuckey@gt5228:/usr/local/src/zangband-2.7.4$ gdb ./zangband
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /usr/local/src/zangband-2.7.4/zangband

Program received signal SIGINT, Interrupt.
Rand_div (m=3) at src/z-rand.c:177
177 if (r < m) break;
(gdb) where
#0 Rand_div (m=3) at src/z-rand.c:177
#1 0x000000000045d071 in get_stats () at src/birth.c:210
#2 0x000000000045df64 in player_birth () at src/birth.c:1432
#3 0x000000000047c255 in play_game (new_game=1 '\001') at src/dungeon.c:3267
#4 0x00000000004b85e3 in main (argc=<value optimized out>,
argv=0x7fff18166808) at src/main.c:733
(gdb) Script done, file is typescript


  • Nobody/Anonymous

    Logged In: NO

    I'm guessing that you are running on a 64 bit system? I have the same issue, but I don't think it is an infinite loop. If you try a random sex, it will eventually choose one, but it takes ~30 secs. I think the RNG doesn't converge in a 64 bit background.

  • Nobody/Anonymous

    Logged In: NO

    The problem is that zangband does not detect 64 bit GCC

    Insert the following code in src/h-type.h at line 106 to fix

    /* detect 64 bit GCC */
    #ifdef _LP64
    #define L64 1
    #define USE_64B 1


Log in to post a comment.