GNU bug report logs - #73420
30.0.90; Race condition in `ansi-osc-apply-on-region' with concurrent user input

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Augusto Stoffel <arstoffel@HIDDEN>; dated Sun, 22 Sep 2024 07:39:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 73420 <at> debbugs.gnu.org:


Received: (at 73420) by debbugs.gnu.org; 22 Sep 2024 08:21:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 22 04:21:37 2024
Received: from localhost ([127.0.0.1]:40838 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ssHqb-0002nT-4O
	for submit <at> debbugs.gnu.org; Sun, 22 Sep 2024 04:21:37 -0400
Received: from eggs.gnu.org ([209.51.188.92]:40788)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ssHqY-0002nH-W1
 for 73420 <at> debbugs.gnu.org; Sun, 22 Sep 2024 04:21:35 -0400
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 <eliz@HIDDEN>)
 id 1ssHq8-0004RI-6Q; Sun, 22 Sep 2024 04:21:08 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=uufN5/XXWwjvOJpVBnIpcErFhGkPsXEkssNw6OSvKew=; b=VcO+eSaujZgI
 N9ifM2F8v6L6NUbUHflQotk5N0ko36hYKcjBGwvzmeKpodMHgcdcc/brm5hBSaiksj7dpCoat/Q5B
 74xrS/itfGmUno/j1o7oFvwhS60zAIMBiRr+JadVe2c5Rh/hgPX6BFV98JsrJ7hXd1HEDEjBShUXJ
 9/9Vzl5sR7rpp0zJ/GBhuNreVJugQyAmq0P2Bxgg6OFHMbBMOb/uhQ4r6RqYalpgK+31Nr2vQA7mR
 2nyyyaKctPfoV/5pJao1oIpEFE/vy1jKEBSkIQXiRVE26nJhqy5GTyMCgeJSVlxNKO2Q6ik2jgTb3
 EXX+NHP2UuFhNTTXxSol5Q==;
Date: Sun, 22 Sep 2024 11:21:04 +0300
Message-Id: <864j68hzf3.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Augusto Stoffel <arstoffel@HIDDEN>
In-Reply-To: <87v7yom94c.fsf@HIDDEN> (message from Augusto Stoffel on Sun, 
 22 Sep 2024 09:37:55 +0200)
Subject: Re: bug#73420: 30.0.90;
 Race condition in `ansi-osc-apply-on-region' with concurrent user
 input
References: <87v7yom94c.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 73420
Cc: Matthias Meulien <orontee@HIDDEN>, 73420 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Augusto Stoffel <arstoffel@HIDDEN>
> Date: Sun, 22 Sep 2024 09:37:55 +0200
> 
> In the current implementation of `ansi-osc-apply-on-region', the
> intention of the calls to `buffer-substring-no-properties' and
> `delete-region' is to get the payload of the OSC control sequence
> currently being parsed.
> 
> However, it is possible that the user typed some characters in the
> buffer while the OSC payload is arriving (and I have actually observed
> this happen if the payload is moderately large).  So
> `buffer-substring-no-properties' should be replaced with something that
> gets the buffer text in that range, but restricted to the portions that
> actually came from the subprocess.

Thanks.  Since you (together with Matthias) are the author of
ansi-osc.el, would you like to propose a solution for this?

> PS: Is there already a version of `filter-buffer-substring' anywhere in
> Emacs that filters based on the value of a given text property, or do
> people bake their own every time?

Looks like the latter, see backtrace--filter-visible, for example.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#73420; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 22 Sep 2024 07:38:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 22 03:38:26 2024
Received: from localhost ([127.0.0.1]:40793 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ssHAn-0000RA-R8
	for submit <at> debbugs.gnu.org; Sun, 22 Sep 2024 03:38:26 -0400
Received: from lists.gnu.org ([209.51.188.17]:60684)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <arstoffel@HIDDEN>) id 1ssHAm-0000R3-Ez
 for submit <at> debbugs.gnu.org; Sun, 22 Sep 2024 03:38:24 -0400
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 <arstoffel@HIDDEN>)
 id 1ssHAQ-0000l2-Rb
 for bug-gnu-emacs@HIDDEN; Sun, 22 Sep 2024 03:38:02 -0400
Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <arstoffel@HIDDEN>)
 id 1ssHAP-0000GC-F8
 for bug-gnu-emacs@HIDDEN; Sun, 22 Sep 2024 03:38:02 -0400
Received: by mail-ed1-x52d.google.com with SMTP id
 4fb4d7f45d1cf-5c4146c7d5dso4398171a12.3
 for <bug-gnu-emacs@HIDDEN>; Sun, 22 Sep 2024 00:38:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1726990679; x=1727595479; darn=gnu.org;
 h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc
 :subject:date:message-id:reply-to;
 bh=CfvxnO9bv/KLsMkGTwkhbgVxlUzGeaxiyTWLdvM+MoQ=;
 b=d55rmHuX3F7DIDhUwmLqwHtu3VkiRgdazF93LduASub2PqihWwnBQQp8evcc91JsR/
 9WJW781y2Ssx0RyhEB/vJ22Tt4glqj8f20M8rXPLd5G+O6eakqmpVtYCDgYOLxnd9UGJ
 WxtcYaU4NdWEfxpONn/LfnDBhRb6eDZnmjDV1UIljs8Us/VrrCKBe3mlZ66LzQ25xYR4
 UcH4XMm+TyDBqWFk0UCG1m5VpVMqQ7y3tQ8a3/UpCweb/0nQmuylM8KrFJPpiI+Ah/uV
 9ORAYugaedYSxGfEbu2Zr/w/RzewdgP5FQiiEhUFQ9+F7ts+ip0ftrBT5nUc/YohJG7o
 CXvw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1726990679; x=1727595479;
 h=mime-version:user-agent:message-id:date:subject:to:from
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=CfvxnO9bv/KLsMkGTwkhbgVxlUzGeaxiyTWLdvM+MoQ=;
 b=ih6tmntdOVwVknudTtWQtmYedjq0OAaQZMJC4c7B17hnrh3QW4TkEaqBUq3kWfzuwQ
 MrUmrh9GdyE53XUSVuWG9omHAPc7qraidv8rtrVZgxqVJfvAewDmH/y3POI26RSkx19T
 z+xVlVlCSIzobOPa8y2aPEGTESQvVWbj6xMnDUDmfcyBukOOghVYDD91FB8LqrNrFDax
 AMU45nQVqxlJXGd0IuW8gDhClLyziWk+f3lWaKeb6IBMT4ChIUiCfE4mpSgrN5XuCJFT
 troZfqVqS10UjtK9dPoEtyCAoJKTpHEUROkFdRRe5e73HnNtNLY0L/jQ37MBuuLjnVCl
 qEnA==
X-Gm-Message-State: AOJu0YxdU0qMFJMNQalCF+aw2NJZvQ+VgVgcB1PL79kzZgJmd8VdgwB1
 AuJ8nMYdHH3qFEdQWIAaHwDWl8l6hgRGYfzeD0NvPb+XxC9EQQI5cpjElQ==
X-Google-Smtp-Source: AGHT+IEPD37JP+KcX8lEMpm0yRsPRcCmYmiY5MJXMJSYaE8zpJ/w3fKsXrQnPgeyFmb+tKGxj8d41A==
X-Received: by 2002:a05:6402:2353:b0:5c5:c059:63ba with SMTP id
 4fb4d7f45d1cf-5c5c0596470mr689651a12.35.1726990678963; 
 Sun, 22 Sep 2024 00:37:58 -0700 (PDT)
Received: from ars3 ([2a02:8109:8a87:ff00::d6f6])
 by smtp.gmail.com with ESMTPSA id
 4fb4d7f45d1cf-5c42bb94a01sm8869660a12.91.2024.09.22.00.37.55
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 22 Sep 2024 00:37:57 -0700 (PDT)
From: Augusto Stoffel <arstoffel@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.90; Race condition in `ansi-osc-apply-on-region' with
 concurrent user input
X-Debbugs-Cc: 
Date: Sun, 22 Sep 2024 09:37:55 +0200
Message-ID: <87v7yom94c.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2a00:1450:4864:20::52d;
 envelope-from=arstoffel@HIDDEN; helo=mail-ed1-x52d.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-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

In the current implementation of `ansi-osc-apply-on-region', the
intention of the calls to `buffer-substring-no-properties' and
`delete-region' is to get the payload of the OSC control sequence
currently being parsed.

However, it is possible that the user typed some characters in the
buffer while the OSC payload is arriving (and I have actually observed
this happen if the payload is moderately large).  So
`buffer-substring-no-properties' should be replaced with something that
gets the buffer text in that range, but restricted to the portions that
actually came from the subprocess.

PS: Is there already a version of `filter-buffer-substring' anywhere in
Emacs that filters based on the value of a given text property, or do
people bake their own every time?




Acknowledgement sent to Augusto Stoffel <arstoffel@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#73420; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 12 Jan 2025 05:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.