Debian Bug report logs - #63843
mawk: random numbers are not always the same (as in C)

version graph

Package: mawk; Maintainer for mawk is Steve Langasek <vorlon@debian.org>; Source for mawk is src:mawk.

Reported by: Santiago Vila <sanvila@unex.es>

Date: Tue, 9 May 2000 15:48:00 UTC

Severity: normal

Tags: fixed-upstream, upstream

Found in version 1.3.3-5

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, sanvila@unex.es, James Troup <awkmaint@nocrew.org>:
Bug#63843; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Santiago Vila <sanvila@unex.es>:
New Bug report received and forwarded. Copy sent to sanvila@unex.es, James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Santiago Vila <sanvila@unex.es>
To: Debian Bugs <submit@bugs.debian.org>
Subject: mawk: random numbers are not always the same (as in C)
Date: Tue, 9 May 2000 17:44:23 +0200 (CEST)
Package: mawk
Version: 1.3.3-5
Severity: wishlist

[ Please, forward this upstream ].

Today I was surprised to discover that mawk's rand() function 
does not always generate the same random numbers on every run.

mawk(1) explains why: "mawk seeds the random number generator from  
the clock at startup so there is no real need to call srand().
Srand(expr) is useful for repeating pseudo random sequences."

However, this behaviour is counter-intuitive from the point of view
of a C programmer, and in fact the other two awk implementations
in Debian do not need an explicit srand() for the random numbers to be
the same on every run.

Would not be possible for mawk to behave the same as gawk in this 
respect?

Thanks.




Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>, mawk@packages.qa.debian.org:
Bug#63843; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Morgon Kanter <morgon@surgo.net>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>, mawk@packages.qa.debian.org. Full text and rfc822 format available.

Message #10 received at 63843@bugs.debian.org (full text, mbox):

From: Morgon Kanter <morgon@surgo.net>
To: 63843@bugs.debian.org
Subject: More info on 63843
Date: Tue, 15 Apr 2003 02:26:00 -0400
[Message part 1 (text/plain, inline)]
I was making a patch just to fixed this, and noticed something a bit 
interesting. Mawk uses a different random number generator than C's 
rand(). I removed the auto-seeding code and tested it, and it would 
just spit out an endless stream of ones. If you really want the patch, 
here it is, but I doubt it'd be that helpful ;)

-- 
Morgon Kanter <morgon@surgo.net> http://www.surgo.net
GPG key ID: 297CEA5B
Please don't CC me on mailing lists, I read them!
[bi_funct.c.patch (text/plain, attachment)]
[Message part 3 (application/pgp-signature, inline)]

Tags added: patch Request was from Morgon Kanter <morgon@surgo.net> to control@bugs.debian.org. Full text and rfc822 format available.

Added tag(s) upstream. Request was from Jonathan Nieder <jrnieder@gmail.com> to control@bugs.debian.org. (Mon, 01 Mar 2010 20:30:03 GMT) Full text and rfc822 format available.

Removed tag(s) patch. Request was from Jonathan Nieder <jrnieder@gmail.com> to control@bugs.debian.org. (Mon, 01 Mar 2010 20:30:03 GMT) Full text and rfc822 format available.

Severity set to 'normal' from 'wishlist' Request was from Jonathan Nieder <jrnieder@gmail.com> to control@bugs.debian.org. (Mon, 01 Mar 2010 20:30:03 GMT) Full text and rfc822 format available.

Reply sent to Jonathan Nieder <jrnieder@gmail.com>:
You have marked Bug as forwarded. (Mon, 01 Mar 2010 20:30:05 GMT) Full text and rfc822 format available.

Message #21 received at 63843-forwarded@bugs.debian.org (full text, mbox):

From: Jonathan Nieder <jrnieder@gmail.com>
To: Thomas E Dickey <dickey@invisible-island.net>, 63843-forwarded@bugs.debian.org
Cc: Santiago Vila <sanvila@unex.es>, Morgon Kanter <morgon@surgo.net>, control@bugs.debian.org
Subject: Re: mawk: random numbers are not always the same (as in C)
Date: Mon, 1 Mar 2010 14:28:46 -0600
tags 63843 + upstream
tags 63843 - patch
severity 63843 normal
thanks

Santiago Vila wrote:

> Today I was surprised to discover that mawk's rand() function 
> does not always generate the same random numbers on every run.
> 
> mawk(1) explains why: "mawk seeds the random number generator from  
> the clock at startup so there is no real need to call srand().
> Srand(expr) is useful for repeating pseudo random sequences."
> 
> However, this behaviour is counter-intuitive from the point of view
> of a C programmer, and in fact the other two awk implementations
> in Debian do not need an explicit srand() for the random numbers to be
> the same on every run.

Yes, this violates POSIX (though I wish it didn’t, since it’s usually
the most convenient behavior).  In fact, the default random sequence
is required to be the same as that produced after srand(1).

The patch at http://bugs.debian.org/63843 is of course unsuitable, but
maybe something similar would work.

Cheers,
Jonathan




Information forwarded to debian-bugs-dist@lists.debian.org, Steve Langasek <vorlon@debian.org>:
Bug#63843; Package mawk. (Thu, 29 Nov 2012 22:09:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to dickey@his.com:
Extra info received and forwarded to list. Copy sent to Steve Langasek <vorlon@debian.org>. (Thu, 29 Nov 2012 22:09:04 GMT) Full text and rfc822 format available.

Message #26 received at 63843@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@his.com>
To: 63843@bugs.debian.org
Cc: 63843-submitter@bugs.debian.org
Subject: re: #63843 mawk: random numbers are not always the same (as in C)
Date: Thu, 29 Nov 2012 17:06:20 -0500
[Message part 1 (text/plain, inline)]
this is done in 1.3.4 20121129

-- 
Thomas E. Dickey <dickey@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
[signature.asc (application/pgp-signature, inline)]

Added tag(s) fixed-upstream. Request was from Thomas Dickey <dickey@his.com> to control@bugs.debian.org. (Thu, 29 Nov 2012 22:09:05 GMT) Full text and rfc822 format available.

Message sent on to Santiago Vila <sanvila@unex.es>:
Bug#63843. (Thu, 29 Nov 2012 22:09:07 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Thu Apr 17 00:09:35 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.