Akari demonstrated this bug to me when a game she codes for was moved from a 32-bit host to a 64-bit host; seed consistency was violated.
Quoting the SF bug:
Even though the source to random.c has changed slightly
since I last checked, it seems that the last 12 bytes
of the 16 byte digest for srand are not being added to
the digest, as shown in function rnd (void buffer) below:
MD5hash(digest, digest, sizeof(unsigned long));
The problem is using sizeof(unsigned long) (which on
32-bit machines tends to be 4 bytes and on 64-bit
machines tends to be 8 bytes), when in fact the digest
size is 16 bytes.
This problem is furthered by the fact that in the
function init_seed (char seed), the digest is
allocated using sizeof(unsigned long) * 4, which can
differ on 64-bit machines, where the unsigned long is
not 32 bits:
if (!(digest = (unsigned long ) malloc(sizeof(unsigned
long) \ 4))) {
In both these cases, none of this will cause a crash,
but it does cause a significant reduction in the
precision of the random seed.
Original issue 28 created by ZetaMUCK on 2014-07-15T06:23:02.000Z:
Stealing a bug from Proto's old Sourceforge site: http://sourceforge.net/p/protomuck/bugs/190/
Akari demonstrated this bug to me when a game she codes for was moved from a 32-bit host to a 64-bit host; seed consistency was violated.
Quoting the SF bug: Even though the source to random.c has changed slightly since I last checked, it seems that the last 12 bytes of the 16 byte digest for srand are not being added to the digest, as shown in function rnd (void buffer) below: MD5hash(digest, digest, sizeof(unsigned long)); The problem is using sizeof(unsigned long) (which on 32-bit machines tends to be 4 bytes and on 64-bit machines tends to be 8 bytes), when in fact the digest size is 16 bytes. This problem is furthered by the fact that in the function init_seed (char seed), the digest is allocated using sizeof(unsigned long) * 4, which can differ on 64-bit machines, where the unsigned long is not 32 bits: if (!(digest = (unsigned long ) malloc(sizeof(unsigned long) \ 4))) { In both these cases, none of this will cause a crash, but it does cause a significant reduction in the precision of the random seed.