From owner-freebsd-current@FreeBSD.ORG Thu Aug 29 21:55:54 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id EE7D951C for ; Thu, 29 Aug 2013 21:55:53 +0000 (UTC) (envelope-from mailer-daemon@vniz.net) Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com [74.125.83.51]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 807582D1A for ; Thu, 29 Aug 2013 21:55:53 +0000 (UTC) Received: by mail-ee0-f51.google.com with SMTP id c1so530106eek.10 for ; Thu, 29 Aug 2013 14:55:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:openpgp:content-type :content-transfer-encoding; bh=aJwkNlOiUSTyzcdh2u42R8i9WOPltqt0p/oCFSZ5fjQ=; b=C+GJHZR+xfTtQKH0QW9DPqRQOU0z7INLfEtjH1zSSTQurCnT77LBKN1jIDoJGtgSeI ElkHgzKcnYOqDhVkro/OH2ZId2/jn7KmPl3Ewwp56wIsz74WCufGYxeb0JsPXhfymGAM V5GBVxTYruuakkw3+SbKmaqhPXno0Pxm9L9EslPndedGHcmCCJ5ATKgQsB4I83m5qaE1 SxgjEWXpCGmAqy4XoOZKyNBVE6mIVTEwviOAgTyduChlsAInq7Gy4ZgTUZsv5VHzx6FX uvY+698fubz/C9XexDRpxxgvN5K3gICrdouNqGP1LHfKdeXEgDyfHHzbocJrMovz0/ob Y6Og== X-Gm-Message-State: ALoCoQkD5Rd/zEy7F6YuUBybEZuOHbd12VCm/x9o1Ly4ZH29MkaPIHbg0yii6+kyLAwnmJth2vqu X-Received: by 10.14.174.195 with SMTP id x43mr7203009eel.47.1377813345678; Thu, 29 Aug 2013 14:55:45 -0700 (PDT) Received: from [192.168.1.2] ([89.169.173.68]) by mx.google.com with ESMTPSA id bn13sm49565716eeb.11.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Aug 2013 14:55:45 -0700 (PDT) Message-ID: <521FC35D.6010503@freebsd.org> Date: Fri, 30 Aug 2013 01:55:41 +0400 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: John Baldwin Subject: Re: RAND_MAX issue? References: <201308291305.09931.jhb@freebsd.org> <521F8FF5.1050904@freebsd.org> In-Reply-To: <521F8FF5.1050904@freebsd.org> OpenPGP: id=964474DD Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org, Jason Helfman X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Aug 2013 21:55:54 -0000 On 29.08.2013 22:16, Andrey Chernov wrote: > On 29.08.2013 21:05, John Baldwin wrote: >> On Thursday, August 29, 2013 11:59:53 am Jason Helfman wrote: >>> I am working on trying to resolve a build issue with devel/libvirt, and >>> posted to the libvirt mailing list, and received this feedback. Please read >>> this thread, and if you have any thoughts I would be interested in any >>> resolution. >>> >>> Here is a link to the thread: >>> https://www.redhat.com/archives/libvir-list/2013-August/msg01544.html >>> >>> Thanks! >> >> It mostly seems to not matter reading the followups. You would need to >> ask Bruce what he thinks about the assumption of RAND_MAX being 2^n-1 >> for some n. >> > > The whole libvirt check looks like Linuxism based on wrong assumption Moreover, their code have totally wrong assumptions: https://www.redhat.com/archives/libvir-list/2013-August/msg01556.html "But I would MUCH rather prefer that FreeBSD revisit their decision, and guarantee that random output be evenly distributed across the full 31 bits to begin with." random() output always is full 31 bit and not related to RAND_MAX anyhow per POSIX. It is only GNU lib which uses RAND_MAX for both rand() and, incorrectly, for random() too. They confess it by themselves in this message: https://www.redhat.com/archives/libvir-list/2013-August/msg01559.html "Huh - the glibc man pages state that random_r returns RAND_MAX bits. random_r is a glibc extension: POSIX only requires rand(), rand_r(), and random(); but even with random(), POSIX has no requirements that it be related to RAND_MAX - so the fact that glibc equates random()/random_r() with RAND_MAX is also a glibc extension." So the correct fix is simple: remove check for RAND_MAX from their sources along with any RAND_MAX usage, since their code don't even use rand() but RAND_MAX is only for rand(). -- http://ache.vniz.net/ bitcoin:1G6ugdNY6e5jx1GVnAU2ntj2NEfmjKG85r