Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91347 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2185 invoked from network); 22 Feb 2016 21:31:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2016 21:31:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.170 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.161.170 mail-yw0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:35400] helo=mail-yw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/AA-25165-C1E7BC65 for ; Mon, 22 Feb 2016 16:31:08 -0500 Received: by mail-yw0-f170.google.com with SMTP id g127so130702491ywf.2 for ; Mon, 22 Feb 2016 13:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=BQUi4sgoAN3BV4U+MpjxUytcFSEelTbZEncTDI7Ml3c=; b=fp5n064wmfJ2iB7e3mLtAacKVS18fmu3B3apYnZxDoCpyciAU5g3WE0VMtzD2dCn2T 8q21CMT006epze7KitnbIx7ch9/ew/E4ByP25LmR+qSaSICyMnRpHxR955pl5ohqjU+C 5plkntXPaa/TK3slDd3jn3EiPonkTOiu8NP8MbV36gX+bXsv8mFcw9TfTdxHWa7EtmXx JxZU8m7VxbPCSkSb6etkv5Zj+8CloR7OTIDTEhqvz14dg9yoNxKXeoMmTzhWFsT7ZF90 FyuJpC0x5mYqRdlH7+wK57/RHIzhQ8eappWnRv/ssqi2tY4Y1sv9XMyDcAROjNbel3+L 4aJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to:content-type; bh=BQUi4sgoAN3BV4U+MpjxUytcFSEelTbZEncTDI7Ml3c=; b=Q7whAw9sFbkw7AQhKPksJMYb5R8PAQmB2xOzyJEZkMy1uZNJS0s7vWtRPrer/ixweX iPb7qmCBFBBP53fisV6x5PyK0qzzMZjyX8hrGBrgdY5TxNsBdW5cugZCaLAzDDATgkJg oYWTcNn2qo9FrVsoYnyoerrodMbGX+xXjVx/T6bIxuKLKI19nusfG6522Q3MHmT0U4eN FQcbOoRWP+5gJv0xjS8IzDoy8Dx/mAo0fstKv5nrYYWI5mxDuHGKPqNZ+O5U93YMT+yq Etlcq2wsU81NvmFDEo4X2TysNDmQGehwK/7BOfEb3co9KD1PFQtW4uAIIy3Mhh3Dom50 9TYw== X-Gm-Message-State: AG10YOQQbk2N/Zo5kiumrxHBgNbNC5MhdRH14XbrS+SL3EO39SnVK01kRz0CRcgZUx45gRbt3vRbUoQB7sNzZw== X-Received: by 10.13.208.2 with SMTP id s2mr7242197ywd.86.1456176664202; Mon, 22 Feb 2016 13:31:04 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.129.109.22 with HTTP; Mon, 22 Feb 2016 13:30:24 -0800 (PST) Date: Tue, 23 Feb 2016 06:30:24 +0900 X-Google-Sender-Auth: MmXNLPGVcTJStryHT32xIoQG7q0 Message-ID: To: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: PRNG: Raise warning and/or provide better pseudo random generator? From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi all, We have issue on pseudo random generators generates only odd/even numbers. https://bugs.php.net/bug.php?id=63174 https://news.ycombinator.com/item?id=9941364 We should raise E_WARNING/E_NOTICE if user supplies random number range that generated random number cannot be random at least. Patch for rand/mt_rand. https://gist.github.com/yohgaki/1519f65dffd66735bafe It seems we need more reliable(fool proof) pseudo random generator. Anyone working on this? We may extends rand()/mt_rand() so that they work with larger range by calling random generators multiple times. If this is implemented, the patch raises errors is not required. mt_rand() extension breaks compatibility with other MT rand implementations, but we already broke it. Therefore, it should not matter. (This was the reason why mt_rand() wasn't made to support 64bit int, IIRC) IMO, we should provide better pseudo random generators than now. Any comments? P.S. I think we should fix mt_rand() to be true MT rand. Function named mt_rand() is not being MT rand is not a nice thing to keep _forever_. -- Yasuo Ohgaki yohgaki@ohgaki.net