From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.bugs Subject: bug#20209: GUILE 2.0.11: crash in set_port_filename_x for bytevector ports Date: Thu, 23 Jun 2016 18:34:09 +0200 Message-ID: <87r3bnn9tq.fsf@pobox.com> References: <87fv8r1pio.fsf@fencepost.gnu.org> <87egob8irs.fsf@netris.org> <87y4mhasqb.fsf@netris.org> <87twx40x7c.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1466700310 15836 80.91.229.3 (23 Jun 2016 16:45:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 Jun 2016 16:45:10 +0000 (UTC) Cc: David Kastrup , 20209@debbugs.gnu.org To: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Jun 23 18:45:00 2016 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bG7kR-0007bw-Lp for guile-bugs@m.gmane.org; Thu, 23 Jun 2016 18:44:59 +0200 Original-Received: from localhost ([::1]:38017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG7kQ-0001yW-Oi for guile-bugs@m.gmane.org; Thu, 23 Jun 2016 12:44:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG7as-0007KV-6V for bug-guile@gnu.org; Thu, 23 Jun 2016 12:35:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bG7an-0001qG-Ts for bug-guile@gnu.org; Thu, 23 Jun 2016 12:35:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40541) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG7an-0001pw-RE for bug-guile@gnu.org; Thu, 23 Jun 2016 12:35:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bG7an-0006gG-Hp for bug-guile@gnu.org; Thu, 23 Jun 2016 12:35:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 23 Jun 2016 16:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20209 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 20209-submit@debbugs.gnu.org id=B20209.146669966125621 (code B ref 20209); Thu, 23 Jun 2016 16:35:01 +0000 Original-Received: (at 20209) by debbugs.gnu.org; 23 Jun 2016 16:34:21 +0000 Original-Received: from localhost ([127.0.0.1]:52878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bG7a9-0006fB-D1 for submit@debbugs.gnu.org; Thu, 23 Jun 2016 12:34:21 -0400 Original-Received: from pb-sasl1.pobox.com ([64.147.108.66]:53832 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bG7a7-0006f2-0O for 20209@debbugs.gnu.org; Thu, 23 Jun 2016 12:34:19 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 674CA244AF; Thu, 23 Jun 2016 12:34:17 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=51Jz35LuNc9fPgKJ/u2/Bw8vaaY=; b=MopupJ zrhTvKGAxBQjSnmEehTgDOCcp+JY58r04zHPxCmHGe7GiwYp2t7ACKbmumTQ568h 3z9e+C0GsolR6X7coq3mLVFbL5xE4Lkn5OXtBlT1PIPA5/jWPeQNAnxVWqqRdeFl HJZBs+AmI1dM2Z4ivgiG0R1hL4XSqEKFBm6os= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=nK6C5e66P4uXxaYR8lVGiUdFxWzTg45b SYjOhHElxfTAs0CKxsARQ3Vi0yfIjKZt917oZKSsWO54hMfnhyde/Cyiie6L+qFW BTi0hrIcWdWw/MAk6xvITdig+pdk82A2NmLzgUrg7XOn4vLnTiO42gsEoz/q6dIc YkGOmmJ9/9g= Original-Received: from pb-sasl1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 50150244AE; Thu, 23 Jun 2016 12:34:17 -0400 (EDT) Original-Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl1.pobox.com (Postfix) with ESMTPSA id 4AFC3244AD; Thu, 23 Jun 2016 12:34:16 -0400 (EDT) In-Reply-To: <87twx40x7c.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Sun, 29 Mar 2015 15:06:47 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Pobox-Relay-ID: 53B8FFA4-3960-11E6-8AE2-C1836462E9F6-02397024!pb-sasl1.pobox.com 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:8170 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sun 29 Mar 2015 15:06, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Mark H Weaver skribis: > >> For these reasons, I decided against recommending those undocumented >> initialization functions. Instead, I suggested that David initialize >> binary ports by loading (ice-9 binary-ports): >> >> (void) scm_c_resolve_module ("ice-9 binary-ports"); > > That sounds like the best option, indeed. > >> For Guile 2.0.12, I suggest that we unconditionally do the equivalent of >> 'scm_init_bytevectors' and 'scm_init_r6rs_ports' during Guile >> initialization, and make those functions into deprecated no-ops. > > Agreed, that=E2=80=99s what I was going to suggest. > > That these init functions are not marked as internal is really an > oversight. > > I wouldn=E2=80=99t be against simply making them SCM_INTERNAL in 2.0.12, = but > making them public + deprecated as you suggest is even better. WDYT about something like this? --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0001-Register-R6RS-port-and-bytevector-internals-early.patch >From f763f353e438de985577ef4b88b805bd4d4c9b77 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Thu, 23 Jun 2016 18:31:55 +0200 Subject: [PATCH] Register R6RS port and bytevector internals early * libguile/bytevectors.c (sym_big, sym_little): Rename from scm_sym_big and scm_sym_little, and don't use the snarf mechanism as we need to initialize this value eagerly in case the C API is used before the Scheme module is loaded. (scm_bootstrap_bytevectors): Initialize the endianness symbols here. * libguile/r6rs-ports.c (scm_register_r6rs_ports): Register the R6RS port kinds here, for the same reason. --- libguile/bytevectors.c | 24 ++++++++++++------------ libguile/r6rs-ports.c | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c index cb7f294..86d1bdf 100644 --- a/libguile/bytevectors.c +++ b/libguile/bytevectors.c @@ -418,8 +418,8 @@ scm_i_print_bytevector (SCM bv, SCM port, scm_print_state *pstate SCM_UNUSED) /* General operations. */ -SCM_SYMBOL (scm_sym_big, "big"); -SCM_SYMBOL (scm_sym_little, "little"); +static SCM sym_big; +static SCM sym_little; SCM scm_endianness_big, scm_endianness_little; @@ -799,13 +799,13 @@ bytevector_large_ref (const char *c_bv, size_t c_size, int signed_p, if (signed_p) { - if (scm_is_eq (endianness, scm_sym_big)) + if (scm_is_eq (endianness, sym_big)) negative_p = c_bv[0] & 0x80; else negative_p = c_bv[c_size - 1] & 0x80; } - c_endianness = scm_is_eq (endianness, scm_sym_big) ? 1 : -1; + c_endianness = scm_is_eq (endianness, sym_big) ? 1 : -1; mpz_init (c_mpz); mpz_import (c_mpz, 1 /* 1 word */, 1 /* word order doesn't matter */, @@ -832,7 +832,7 @@ bytevector_large_set (char *c_bv, size_t c_size, int signed_p, mpz_t c_mpz; int c_endianness, c_sign, err = 0; - c_endianness = scm_is_eq (endianness, scm_sym_big) ? 1 : -1; + c_endianness = scm_is_eq (endianness, sym_big) ? 1 : -1; mpz_init (c_mpz); scm_to_mpz (value, c_mpz); @@ -1864,9 +1864,9 @@ utf_encoding_name (char *name, size_t utf_width, SCM endianness) ? "32" : "??")))); strcat (name, - ((scm_is_eq (endianness, scm_sym_big)) + ((scm_is_eq (endianness, sym_big)) ? "BE" - : ((scm_is_eq (endianness, scm_sym_little)) + : ((scm_is_eq (endianness, sym_little)) ? "LE" : "unknown"))); } @@ -1884,7 +1884,7 @@ utf_encoding_name (char *name, size_t utf_width, SCM endianness) \ SCM_VALIDATE_STRING (1, str); \ if (scm_is_eq (endianness, SCM_UNDEFINED)) \ - endianness = scm_sym_big; \ + endianness = sym_big; \ else \ SCM_VALIDATE_SYMBOL (2, endianness); \ \ @@ -2001,7 +2001,7 @@ SCM_DEFINE (scm_string_to_utf32, "string->utf32", \ SCM_VALIDATE_BYTEVECTOR (1, utf); \ if (scm_is_eq (endianness, SCM_UNDEFINED)) \ - endianness = scm_sym_big; \ + endianness = sym_big; \ else \ SCM_VALIDATE_SYMBOL (2, endianness); \ \ @@ -2266,13 +2266,13 @@ scm_bootstrap_bytevectors (void) (scm_i_array_element_types[SCM_ARRAY_ELEMENT_TYPE_VU8], scm_make_bytevector); } + + scm_endianness_big = sym_big = scm_from_latin1_symbol ("big"); + scm_endianness_little = sym_little = scm_from_latin1_symbol ("little"); } void scm_init_bytevectors (void) { #include "libguile/bytevectors.x" - - scm_endianness_big = scm_sym_big; - scm_endianness_little = scm_sym_little; } diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c index bd8a1c4..5d283d2 100644 --- a/libguile/r6rs-ports.c +++ b/libguile/r6rs-ports.c @@ -1400,12 +1400,6 @@ scm_register_r6rs_ports (void) "scm_init_r6rs_ports", (scm_t_extension_init_func) scm_init_r6rs_ports, NULL); -} - -void -scm_init_r6rs_ports (void) -{ -#include "libguile/r6rs-ports.x" initialize_bytevector_input_ports (); initialize_custom_binary_input_ports (); @@ -1413,3 +1407,9 @@ scm_init_r6rs_ports (void) initialize_custom_binary_output_ports (); initialize_transcoded_ports (); } + +void +scm_init_r6rs_ports (void) +{ +#include "libguile/r6rs-ports.x" +} -- 2.8.3 --=-=-=--