From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Newsgroups: gmane.lisp.guile.bugs Subject: bug#60779: =?UTF-8?Q?=E2=80=98SCM=5FF=5FBYTEVECTOR=5FIMMUTABLE=E2=80=99?= is not honored by bytevector instructions Date: Fri, 13 Jan 2023 12:24:30 +0100 Message-ID: <87a62meky9.fsf@inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26419"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) To: 60779@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Fri Jan 13 12:25:26 2023 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pGIBZ-0006g0-HG for guile-bugs@m.gmane-mx.org; Fri, 13 Jan 2023 12:25:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGIBN-0001jN-Hu; Fri, 13 Jan 2023 06:25:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGIBE-0001iV-J2 for bug-guile@gnu.org; Fri, 13 Jan 2023 06:25:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pGIBC-0008WF-Nr for bug-guile@gnu.org; Fri, 13 Jan 2023 06:25:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pGIBB-0008Ho-TK for bug-guile@gnu.org; Fri, 13 Jan 2023 06:25:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 13 Jan 2023 11:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60779 X-GNU-PR-Package: guile X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167360907531795 (code B ref -1); Fri, 13 Jan 2023 11:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Jan 2023 11:24:35 +0000 Original-Received: from localhost ([127.0.0.1]:49750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGIAk-0008Gk-L8 for submit@debbugs.gnu.org; Fri, 13 Jan 2023 06:24:35 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:32808) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGIAj-0008Gd-Tw for submit@debbugs.gnu.org; Fri, 13 Jan 2023 06:24:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGIAj-0001YK-Oj for bug-guile@gnu.org; Fri, 13 Jan 2023 06:24:33 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGIAj-0008QP-Gu for bug-guile@gnu.org; Fri, 13 Jan 2023 06:24:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=eD44wXp4uR+PiQBb4MC5c7S0NQpgkYPc3Xjs6wMTTas=; b=Sxi8lUlQa0GS9S WP95fYqufy0vtCoBhR/g6sbxAZ0/UBQbNEQolRJEe9yMaSI8Rnr/ETM62dGQFWctRpjn55LPFgYhV r+U6EOviozcthW6aiddv7ZIc12A+AzioLItWiXMrAQeaRryuXUfr8sv23yMAQ8EddaJH9yXktGw30 3C//HZZEkofOH9mLayc0BgxZItxYbrafUKidMPJa4scrC3my2+Q7lJIzc5vFqajgi99RDzwYStoDf t6k1kDof55KQoLz58O1Mx5InDfA6ntmi2b30hogZTBvvetfzYaS7J/C1ImjZgy7tnIBw1HYQzmoGu uNCxtTX9yi0BCHKVNJ6g==; Original-Received: from [193.50.110.246] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGIAj-00084Q-1R for bug-guile@gnu.org; Fri, 13 Jan 2023 06:24:33 -0500 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Quartidi 24 =?UTF-8?Q?Niv=C3=B4se?= an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour du Cuivre X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.bugs:10509 Archived-At: Bytevector literals are marked as =E2=80=98SCM_F_BYTEVECTOR_IMMUTABLE=E2=80= =99, but VM instructions that access bytevectors do not check that flag, which can lead to segfaults: --8<---------------cut here---------------start------------->8--- $ cat t.scm (use-modules (rnrs bytevectors)) (define bv #vu8(1 2 3)) (bytevector-u8-set! bv 0 1) $ guild compile -O2 t.scm wrote `/home/ludo/.cache/guile/ccache/3.0-LE-8-4.6/data/src/guile-3.0/t.scm= .go' $ guile t.scm Segmentation fault --8<---------------cut here---------------end--------------->8--- Conversely, the subrs from bytevector.c do check the flag: --8<---------------cut here---------------start------------->8--- $ guild compile -O0 t.scm wrote `/home/ludo/.cache/guile/ccache/3.0-LE-8-4.6/data/src/guile-3.0/t.scm= .go' $ guile t.scm Backtrace: In ice-9/boot-9.scm: 1752:10 6 (with-exception-handler _ _ #:unwind? _ # _) In unknown file: 5 (apply-smob/0 #) In ice-9/boot-9.scm: 724:2 4 (call-with-prompt ("prompt") # =E2=80=A6) In ice-9/eval.scm: 619:8 3 (_ #(#(#))) In ice-9/boot-9.scm: 2836:4 2 (save-module-excursion #) 4388:12 1 (_) In unknown file: 0 (bytevector-u8-set! #vu8(1 2 3) 0 1) ERROR: In procedure bytevector-u8-set!: In procedure bytevector-u8-set!: Wrong type argument in position 1 (expecti= ng mutable bytevector): #vu8(1 2 3) $ guile --version guile (GNU Guile) 3.0.8 Copyright (C) 2021 Free Software Foundation, Inc. License LGPLv3+: GNU LGPL 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. --8<---------------cut here---------------end--------------->8--- I suppose the immutability test would have to be done not at the level of individual VM instructions but at a higher-level in generated code, such that the compiler could lift the test outside loops that access bytevectors, similar to what it does with =E2=80=98heap-object?=E2=80=99. Ludo=E2=80=99.