From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom de Vries Newsgroups: gmane.lisp.guile.bugs Subject: bug#33044: Analysis and proposed patch Date: Mon, 15 Oct 2018 20:59:03 +0200 Message-ID: <8a6a308f-a981-fd46-93d5-c2d2870f4eb4@suse.de> References: <469f2345-5e76-1fc5-1105-f1d508611140@suse.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1539629945 31269 195.159.176.226 (15 Oct 2018 18:59:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 15 Oct 2018 18:59:05 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 To: 33044@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Oct 15 20:59:01 2018 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gC84x-000812-Rd for guile-bugs@m.gmane.org; Mon, 15 Oct 2018 20:58:59 +0200 Original-Received: from localhost ([::1]:54384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gC874-0004gL-HF for guile-bugs@m.gmane.org; Mon, 15 Oct 2018 15:01:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gC862-0004Ai-Lv for bug-guile@gnu.org; Mon, 15 Oct 2018 15:00:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gC85z-0002V6-5I for bug-guile@gnu.org; Mon, 15 Oct 2018 15:00:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47161) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gC85z-0002UP-1N for bug-guile@gnu.org; Mon, 15 Oct 2018 15:00:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gC85y-0000rG-RX for bug-guile@gnu.org; Mon, 15 Oct 2018 15:00:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <469f2345-5e76-1fc5-1105-f1d508611140@suse.de> Resent-From: Tom de Vries Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 15 Oct 2018 19:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33044 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 33044-submit@debbugs.gnu.org id=B33044.15396299463198 (code B ref 33044); Mon, 15 Oct 2018 19:00:02 +0000 Original-Received: (at 33044) by debbugs.gnu.org; 15 Oct 2018 18:59:06 +0000 Original-Received: from localhost ([127.0.0.1]:51419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gC854-0000pV-AB for submit@debbugs.gnu.org; Mon, 15 Oct 2018 14:59:06 -0400 Original-Received: from mx2.suse.de ([195.135.220.15]:46804 helo=mx1.suse.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gC850-0000ow-3p for 33044@debbugs.gnu.org; Mon, 15 Oct 2018 14:59:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Original-Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F2583ADA9 for <33044@debbugs.gnu.org>; Mon, 15 Oct 2018 18:58:55 +0000 (UTC) Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:9196 Archived-At: Hi, I think there are two independent problems here. ------- 1. scm_seed_to_random_state should be able to handle the case that the seed argument is a non-narrow string. 2. The *random-state* variable is documented like this: ... Note that the initial value of *random-state* is the same every time Guile starts up. Therefore, if you don’t pass a state parameter to the above procedures, and you don’t set *random-state* to (seed->random-state your-seed), where your-seed is something that isn’t the same every time, you’ll get the same sequence of “random” numbers on every run. ... However, using scm_from_locale_string to initialize *random-state* makes it possible that *random-state* differs depending on the locale used when starting Guile. So, we should use a string that's independent of the locale settings. ------- The second problem is fixed by using scm_from_latin1_string instead of scm_from_locale_string: ... diff --git a/libguile/random.c b/libguile/random.c index 4051d1f..6f014e1 100644 --- a/libguile/random.c +++ b/libguile/random.c @@ -374,7 +374,7 @@ make_rstate (scm_t_rstate *state) * Scheme level interface. */ -SCM_GLOBAL_VARIABLE_INIT (scm_var_random_state, "*random-state*", scm_seed_to_random_state (scm_from_locale_string ("URL:http://stat.fsu.edu/~geo/diehard.html"))); +SCM_GLOBAL_VARIABLE_INIT (scm_var_random_state, "*random-state*", scm_seed_to_random_state (scm_from_latin1_string ("URL:http://stat.fsu.edu/~geo/diehard.html"))); SCM_DEFINE (scm_random, "random", 1, 1, 0, (SCM n, SCM state), ... Tested on 2.0.14 and 2.2.4 tarballs. Thanks, - Tom