From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: vibhavp@gmail.com Newsgroups: gmane.emacs.devel Subject: Re: scratch/comp-static-data 5aa3db2f11: comp: Add support for compiling elisp constants into static data. Date: Mon, 21 Nov 2022 21:29:11 +0530 Message-ID: <6735426c1ff66c639ac26e6ae9bb9fffae99f2d7.camel@gmail.com> References: <166844679660.19180.3470364122428955894@vcs2.savannah.gnu.org> <20221114172637.78215C0E4C7@vcs2.savannah.gnu.org> <871qq5hxf9.fsf@yahoo.com> <9c27dd84e3298e2ed979415016f2db75d1cef882.camel@gmail.com> <83zgcobr9x.fsf@gnu.org> <83zgcm5b60.fsf@gnu.org> <18b7286a9bd88d8c30822d195d9893f1267fd665.camel@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-tpUTn/KRhDY2gzPT/RpI" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="903"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.46.1 Cc: rms@gnu.org, akrl@sdf.org, emacs-devel@gnu.org To: Stefan Monnier , Eli Zaretskii , Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 21 17:00:19 2022 Return-path: Envelope-to: ged-emacs-devel@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 1ox9DX-000AdO-8s for ged-emacs-devel@m.gmane-mx.org; Mon, 21 Nov 2022 17:00:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox9Cp-000418-Of; Mon, 21 Nov 2022 10:59:35 -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 1ox9Ck-00040J-Cl for emacs-devel@gnu.org; Mon, 21 Nov 2022 10:59:30 -0500 Original-Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ox9Ch-00044L-Lw; Mon, 21 Nov 2022 10:59:30 -0500 Original-Received: by mail-ed1-x531.google.com with SMTP id e13so16883958edj.7; Mon, 21 Nov 2022 07:59:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:references:in-reply-to:date:cc:to:from :subject:message-id:from:to:cc:subject:date:message-id:reply-to; bh=UKz9LFmiCIKLAI4W3zzmidxpJwpXSkIvja2Uhg5vmyc=; b=O4kovIX64Y+HadwyBkg0+6iJpf3Hub9vAAHa+FckMTZ/7XjfW/Z2s1vkMwimUTg9uH CNFJRdj6vHgf8OAfAh9HDjRJkIPhjdGax8d9hPNJbqmSKa95r4vVi3S+TsSOtM04VE+u 2kDhiHfFKAlvTNCfG33gSWLKuCqA+p6SNCAuaObt+Ty6E0UqfbvfaA4thqpiddvs+Xy4 aI2Y3Oh/kMjWlJ+/+RF9QxtuSePjOy8NasOAd6OqeiWuPVTtTQ6RKH5r/ZRWms36sNYo HKM3oTVm2xFudZso3nSmCGA/TFn/Aq7q+ms7HaAaUdkomkWfhGECvDNHYbadlEVedUik 8J6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:references:in-reply-to:date:cc:to:from :subject:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=UKz9LFmiCIKLAI4W3zzmidxpJwpXSkIvja2Uhg5vmyc=; b=RPFaMZY4f9xFVPOOlTPW+RX7L6pCjrbX7yVMAxOryv5W6Q2kmrGPrjuX7txGWEPyRS hpyEN6pdRnpydorhuhsYRdE1L1bGDKGV92NFEFQd4s+mXE/xxe0G4nzTVnuKrHcNPtnQ juGODrvqXdhll5lPzEQqaMTHIRwrqMpxM6MkgbnpWskQJEFLPSLuScdpJCU9tqo82P4n t65IjcU749WVnHx05KvJoqhiEwsOHh66dKFMq+S2WdbUyTr63eZf9c2D4JVsyzNFG/3Z PM7EkFbI11av4oV0OpPRgpnmcHLZUY+w0T2Mp44Iv6Bvd+qouXMxf7yxjncZJsf/Yolf tV7w== X-Gm-Message-State: ANoB5pntQ5u3JkQ/WzSWbb/0tfboOR5azI+gmtqKXdfiI8SsyphgiXAx 05M2IRfTwzsQVzco7nNIVOk= X-Google-Smtp-Source: AA0mqf51zdp94E5172ZhcDpKp9Hhv8KvLODd4EOoG+zBDxcoOBsksSTt3gSREwO0m+qy9XK1oc856A== X-Received: by 2002:a05:6402:3892:b0:454:cbef:c161 with SMTP id fd18-20020a056402389200b00454cbefc161mr17587031edb.365.1669046365131; Mon, 21 Nov 2022 07:59:25 -0800 (PST) Original-Received: from [192.168.1.3] ([182.69.181.216]) by smtp.gmail.com with ESMTPSA id dk1-20020a170906f0c100b0078d22b0bcf2sm5061210ejb.168.2022.11.21.07.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 07:59:23 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=vibhavp@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300302 Archived-At: --=-tpUTn/KRhDY2gzPT/RpI Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 2022-11-20 at 13:47 -0500, Stefan Monnier wrote: > > The follow elisp snipper is an example of code that when compiled > > under > > this branch, crashes Emacs: > > ;; -*- lexical-binding: t; -*- > > (defun fault-function () > > =C2=A0 (let ((a [1 2 3])) > > =C2=A0=C2=A0=C2=A0 (aset a 0 5) > > =C2=A0=C2=A0=C2=A0 a)) >=20 > I'm not deluded enough to think it's currently impossible to crash > Emacs > with a well-crafted piece of ELisp code, but we do aim for that, so > this > would be a significant step backwards :-( >=20 > Can we change your patch so that it makes the section writable rather > than ".rodata"? >=20 Indeed, making static lisp data variables constants was an afterthought before I pushed the first draft. Currently, it's line 2889 in src/comp.c@320e9ab048. Removing the call to `gcc_jit_type_get_const' should make them writeable as usual. However, as part of emitting the lisp data as read only, I also made it so that such objects have their GC mark bit set, so that GC does not crash Emacs as it attemps to mark these objects, skipping them instead. This property can therefore be used to check whether an object being modified is mutable or not =C3=A0 la `CHECK_IMPURE'. A more general variant of the macro, `CHECK_MUTABLE' could be defined as (PURE_P (ptr) || object_marked_p (ptr) ? pure_wire_error (obj) : (void) 0) This lets us keep them as read-only and preventing illegal modifications resulting in a crash. If this sounds good, I try adding these changes soon, otherwise remove the call to `gcc_jit_type_get_const'. Best, Vibhav --=20 Vibhav Pant vibhavp@gmail.com GPG: 7ED1 D48C 513C A024 BE3A 785F E3FB 28CB 6AB5 9598 --=-tpUTn/KRhDY2gzPT/RpI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iQFGBAABCAAwFiEEftHUjFE8oCS+Onhf4/soy2q1lZgFAmN7oE8SHHZpYmhhdnBA Z21haWwuY29tAAoJEOP7KMtqtZWYFLUIAIhhivk5q5lwqInoH9IcC0oUrIy87PX4 OYwCA0r0P9+EN0WJOXLI5riANHeuA+Aj4zxB7vP9BPW945OKpp+VrZJSsUeeaNXk A1sTmeY5mZcrOePYs7RTANXTtTXxX9m9Wa9qyhd3RVtwA+kmwyFwBzmg7hJ0QyxZ QOHC9napJzGQeqBHI1BxPwseMx3ETqV7bvPT3ZXfjATKJmcrCm1uYZquYUbb+DhV zbdVLfzABwfXGRWadiFM/Y7N6Nqspf5cx+tiPco3jj7OU0hC569InUqzosfMVU1Z b4E/oFT5jmca4A7/q4gHgL4wAdcUmT0QR2fXGkUBdORdmdUAk9KnyhM= =/j55 -----END PGP SIGNATURE----- --=-tpUTn/KRhDY2gzPT/RpI--