From owner-svn-src-head@FreeBSD.ORG Tue Jul 2 15:51:29 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 68166BAF for ; Tue, 2 Jul 2013 15:51:29 +0000 (UTC) (envelope-from mailer-daemon@vniz.net) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com [209.85.215.53]) by mx1.freebsd.org (Postfix) with ESMTP id E3E1C16C2 for ; Tue, 2 Jul 2013 15:51:28 +0000 (UTC) Received: by mail-la0-f53.google.com with SMTP id fs12so5693032lab.26 for ; Tue, 02 Jul 2013 08:51:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:openpgp:content-type :content-transfer-encoding:x-gm-message-state; bh=Uikhacxpo9Ka9PlcOKzkYDEQgVyjxc8UGxY6QY5mFRk=; b=Z+3bpq+nSJFRnT/XXFyCSQRkb0K5aK9cusx3A2xyhIu5KdwuCK6/dy24nhUuiNdRIl N8aVKcWkCti0L7cdA0QhekIFBk77VTTAd0LTyg1v7H+WzaVSTzrQBCFJ+dfjzb94LwKs khfzaPeVThzI8nAFaRzr4ny+72j+baENCa5F0vyhOXJllb1TM0TAxcRREo7JLQyuWb5f OIT1I9s+AQLZrimLyP1kF9EqVnCziiZZrSzV5/sCZn6WfBes7AheGEjVq1IG3ma9HL6q El/K0lszdROz2SN+kHVvkUkcMNA4CVtBrLqbhpOZyO6O0UCFOX3T7eSXCqCCpvh5d/In G6Uw== X-Received: by 10.152.2.168 with SMTP id 8mr14566165lav.69.1372779918558; Tue, 02 Jul 2013 08:45:18 -0700 (PDT) Received: from [192.168.1.2] ([89.169.163.3]) by mx.google.com with ESMTPSA id m1sm9291403lag.3.2013.07.02.08.45.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Jul 2013 08:45:18 -0700 (PDT) Message-ID: <51D2F571.8050108@freebsd.org> Date: Tue, 02 Jul 2013 19:44:49 +0400 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: Bruce Evans Subject: Re: RAND_MAX broken References: <201307012143.r61Lhemi067176@svn.freebsd.org> <20130702130818.V865@besplex.bde.org> <20130702165642.X1571@besplex.bde.org> In-Reply-To: <20130702165642.X1571@besplex.bde.org> OpenPGP: id=964474DD Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQm992DTbcMbEXcnCq7Z9/0x6FDXqHkWDUOdyaZaYpHjOLXl7uGSWQHnn5ssBAtbPvATMzrJ Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, "Pedro F. Giffuni" , src-committers@FreeBSD.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2013 15:51:29 -0000 On 02.07.2013 11:39, Bruce Evans wrote: > The bugs are a little different than I said above. There is no overflow > problem and no problem with invalid values being produces, since the > algorithm from ACM is careful to do everything with 32 bit signed > integers without causing overflow. The algorithm just doesn't produce > values mod 2**32 as expected by all the functions. It does what it > claims to do -- it produces values mod (2**32 - 1). The largest bug > is that RAND_MAX is off by 1. It is specified as the largest value > returned by rand(), but in FreeBSD rand() never returns it unless > USE_WEAK_SEEDING is confgured. The values should be unifornly > distributed on average beteen 0 and RAND_MAX,but that is impossible > if RADND_MAX is never returned. From libc/stdlib/srand.c: Don't ever consider USE_WEAK_SEEDING defined - result is distributet _very_ poorly and the code should be removed long time ago. BTW, I don't understand well fixes you suggest. Is it to define RAND_MAX as 0x7ffffffe ? -- http://ache.vniz.net/ bitcoin:13fGiNutKNHcVSsgtGQ7bQ5kgUKgEQHn7N