From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#75322: SAFE_ALLOCA assumed to root Lisp_Objects/SSDATA(string) Date: Sat, 04 Jan 2025 11:20:41 +0100 Message-ID: References: <87jzbbke6u.fsf@protonmail.com> <87msg7iq0o.fsf@protonmail.com> <86ed1jf1tp.fsf@gnu.org> <865xmugawr.fsf@gnu.org> 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="20613"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: pipcet@protonmail.com, 75322@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 04 11:21:14 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1tU1HN-0005CO-2g for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Jan 2025 11:21:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tU1HF-0008Jx-ET; Sat, 04 Jan 2025 05:21:05 -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 1tU1HC-0008JP-SN for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 05:21:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tU1HC-0001qz-Ca for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 05:21:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=+4uOErmjVKuM04kD64lbqLb5qri+0NhydyRtv+c7TLc=; b=buybIvxVUZ+3FiMgKi7q5nto4p2aFoJ3M7sC2FKkBrNrwKxeN/A0EfuJzpIcXLp7/kUyKnByuu/YDI5d99gWZ7zsmaeEkc/JblDh4gOYetqyZV9YfLHXmLSYlBevPJSIg+D/kl6V8nUydpp1BOAoD7qpM5qF43XVwInmCRVpKySSyziSqAfWPBEDOAePvJKRT3lPyo6vIMf6jONBc8Vc2JhTOhQhAEE0Sad+U88RNmepjwe+zOPFmgN+eX0V337u+qZX0+x8oeZPZgKLKu10cntTnP+WDco+3VyWaEQ3XEs/qOUwMEU0vHi5TOP+NOr7eGT3LHTg7YiiZIZ6InVjtg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tU1HC-0007mw-6t for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 05:21:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Jan 2025 10:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75322 X-GNU-PR-Package: emacs Original-Received: via spool by 75322-submit@debbugs.gnu.org id=B75322.173598605229912 (code B ref 75322); Sat, 04 Jan 2025 10:21:02 +0000 Original-Received: (at 75322) by debbugs.gnu.org; 4 Jan 2025 10:20:52 +0000 Original-Received: from localhost ([127.0.0.1]:53472 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tU1H2-0007mO-Br for submit@debbugs.gnu.org; Sat, 04 Jan 2025 05:20:52 -0500 Original-Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:45171) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tU1H0-0007m9-2Z for 75322@debbugs.gnu.org; Sat, 04 Jan 2025 05:20:51 -0500 Original-Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-435f8f29f8aso93496955e9.2 for <75322@debbugs.gnu.org>; Sat, 04 Jan 2025 02:20:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735986043; x=1736590843; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+4uOErmjVKuM04kD64lbqLb5qri+0NhydyRtv+c7TLc=; b=IrVfReDhskotUFWayYFnOfHaxhihx38d6lhRkV3Gy/7+GNvAvMk++WPwGzg1wfX8OE yAu/ARNfpeUGX4atLhblsBiXmO2mY4e0D9DzX0g0mZcEXN9Lb23XySOeKWOYG0+M1KVt YciK3QxPbdF+nOyOG9UKJO9ckcI6txLyXdO3OR2YRJ0HtwrU6rr3xc+vtDjvMnRsPeoX j+fP66O5dmRD9Yx3KvHah7o4vigaXwuZ5pkwwE1wEvmt7+VSoad+JSAGZ5yM7iT2FRzL RuvpZ2gDUgksoe05IO8laALpGSsQ2dHgfTmcqMWGnJi2a1uiiEvD5KmXbTMaDSHtHBHi 5VhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735986043; x=1736590843; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to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h0cJf6v7OY1Zz6Fu69adS22GK4fLQ== X-Received: by 2002:a5d:5e09:0:b0:386:3213:5b9d with SMTP id ffacd0b85a97d-38a223fd110mr41465447f8f.41.1735986043320; Sat, 04 Jan 2025 02:20:43 -0800 (PST) Original-Received: from pro2 (p200300e0b73c9f00c50ae305bf989514.dip0.t-ipconnect.de. [2003:e0:b73c:9f00:c50a:e305:bf98:9514]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c84722dsm42855256f8f.53.2025.01.04.02.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jan 2025 02:20:42 -0800 (PST) In-Reply-To: <865xmugawr.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 04 Jan 2025 11:56:20 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298355 Archived-At: Eli Zaretskii writes: >> From: Gerd M=C3=B6llmann >> Cc: pipcet@protonmail.com, 75322@debbugs.gnu.org >> Date: Sat, 04 Jan 2025 09:47:43 +0100 >>=20 >> Eli Zaretskii writes: >>=20 >> > Let's discuss this on a case by case basis. Not all uses of alloca >> > are the same or have the same requirements and restrictions. >>=20 >> Okay. For the SDATA case, I find Pip's commit does the right thing. It >> uses xstrdup for the strings and makes sure these are freed later by >> registering them in one of the special specpdl entries that exist for >> that purpose (record_unwind_protect_ptr). Works with both GCs, is always >> safe, I don't see disadvantages, and we don't have to check if GC runs >> or not and compact strings (old) or moves string data around (igc). > > The disadvantage is to xstrdup strings when that is not needed. It > increases memory pressure and also costs some CPU time. Not very > significant disadvantage, admittedly, but still. If this is needed, > it's a small price to pay, but if it isn't needed, it's a waste. That's true. > > So let's see if we agree that it is indeed needed. The way to do that > is to explain how GC could happen while the code which assembles the > environment in make_environment_block and the code in emacs_spawn > afterwards run. Note that we block SIGCHLD and block input while > emacs_spawn runs. I'm sorry, but I'm afraid that's not something for me. The possible gains are so small that I don't want to spend time checking this. >> For the Lisp_Object cases, I strongly suspect that these cases are an >> oversight and were left over when SAFE_ALLOCA_LISP was introduced. The >> reason for introducing SAFE_ALLOCA_LISP is, IMO, what Pip said (old GC): >> to make sure that the Lisp_Objects are marked, via specpdl stack entries >> again, when the specpdl stack(s) are marked. Not doing that looks >> definitely wrong. Replacing the other ALLOCA macros that are currently >> used for holding Lisp_Objects with SAFE_ALLOCA_LISP would solve things >> for both GCs. > > Can we first identify those cases, so that we could discuss the > specific codes in question? Okay. Pip talked about callproc.c and process.c. I believe process.c is the one with the SDATA. In callproc.c I found two: call_process and create_temp_file both use SAFE_NALLOCA to store Lisp_Objects. I think these should be replaces with SAVE_ALLOCA_LISP.