From: Tom de Vries <tdevries@suse.de>
To: 33044@debbugs.gnu.org
Subject: bug#33044: Analysis and proposed patch
Date: Mon, 15 Oct 2018 20:59:03 +0200 [thread overview]
Message-ID: <8a6a308f-a981-fd46-93d5-c2d2870f4eb4@suse.de> (raw)
In-Reply-To: <469f2345-5e76-1fc5-1105-f1d508611140@suse.de>
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
next prev parent reply other threads:[~2018-10-15 18:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-15 8:44 bug#33044: Invalid read access of chars of wide string in scm_seed_to_random_state Tom de Vries
2018-10-15 14:20 ` bug#33044: Reproduced using guile binary Tom de Vries
2018-10-21 16:24 ` Tom de Vries
2018-10-15 18:59 ` Tom de Vries [this message]
2018-10-16 1:57 ` bug#33044: Guile misbehaves in the "ja_JP.sjis" locale Mark H Weaver
2018-10-16 5:13 ` Mark H Weaver
2018-10-16 12:52 ` John Cowan
2018-10-16 23:38 ` Tom de Vries
2018-10-17 7:00 ` Tom de Vries
2018-10-16 23:27 ` Tom de Vries
2018-10-18 1:56 ` Mark H Weaver
2018-10-18 10:26 ` Tom de Vries
2018-10-20 2:24 ` Mark H Weaver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a6a308f-a981-fd46-93d5-c2d2870f4eb4@suse.de \
--to=tdevries@suse.de \
--cc=33044@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).