From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Stephani via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65796: dynamic module non_local_exit_get overwrites exit signals Date: Thu, 7 Sep 2023 12:24:03 +0200 Message-ID: References: <8334zq1mx6.fsf@gnu.org> Reply-To: Philipp Stephani 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="1368"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Xinyang Chen , p.stephani2@gmail.com, Daniel Colascione , 65796@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 07 12:25:42 2023 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 1qeCCk-00007Q-1q for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 07 Sep 2023 12:25:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeCCU-0002RK-4k; Thu, 07 Sep 2023 06:25:26 -0400 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 1qeCCO-0002Ql-0l for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2023 06:25:21 -0400 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 1qeCC5-0000ul-13 for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2023 06:25:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qeCC6-0005P1-HU for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2023 06:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Stephani Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Sep 2023 10:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65796 X-GNU-PR-Package: emacs Original-Received: via spool by 65796-submit@debbugs.gnu.org id=B65796.169408227020702 (code B ref 65796); Thu, 07 Sep 2023 10:25:02 +0000 Original-Received: (at 65796) by debbugs.gnu.org; 7 Sep 2023 10:24:30 +0000 Original-Received: from localhost ([127.0.0.1]:38698 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeCBa-0005Np-1u for submit@debbugs.gnu.org; Thu, 07 Sep 2023 06:24:30 -0400 Original-Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:36089) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeCBY-0005Nd-Lw for 65796@debbugs.gnu.org; Thu, 07 Sep 2023 06:24:29 -0400 Original-Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-51e24210395so11114a12.0 for <65796@debbugs.gnu.org>; Thu, 07 Sep 2023 03:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1694082261; x=1694687061; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QMqBwGul96xihfaV6H0gOMf/kK0hd+bVLZwS3P7t9LY=; b=vD77yKWwMbY+OAE82PhMc1a+A/FqLQ3pB71hWn8RjHMldSq5kz5vJTRy2WFvrUIlye pm3j+EUnzVho660iSh5gSXqDSIeDTjXa6vQq+tB7gB/xmqtzcU0ZR1YEqpRvp5b2p8v+ 80a0g0yc8ZPL2cvRL4aw5fAshXm/GIzFi2jIPy21s7qjL4mQACAv4CKfVTzpY2gpWJ9j 2gai2pS3Di6kmRgq9QBL4sbI3+EJWxCyCQff0K+k9OZEYdyrzlL1sW8tc7aTewqX0eHl 71gV5ubRD1PXqZryBd9fILA2kCDGtvTa/alhKS+iNSFisrvj+CC+dtBy7FQct7LBEq8W mIiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694082261; x=1694687061; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QMqBwGul96xihfaV6H0gOMf/kK0hd+bVLZwS3P7t9LY=; b=FQUMZrcffRTemRACQ0TIm8rC6J+fLmWSjM9G8Q+E7ahqHz3uxwv5D+TMg5WP4l49aW LmPm0sAPjlCOVP0IwjP5JLG14a7unmMdCT16BTUr2brZpe7Kma+v+nacQyZgUxAxke8g LFBKOtwhj5REANU5KcuKs56jmhh1PkjGt9s2dfHdjbZVHC2ug4AH5TZeqrpF7ZEw7GxK BRatCU6P/jvsm3LvrPP5QvIYv8HJ/Ah5PGBdBodWTessL4jC0IrcPc49ror3jfMfsol1 ZFzbRkpn3jPW9hwUFJlvIPyIDripMkU+itZG4SCccn0kzVPKnPL3vH0O3KzO3R2I74PD 3T4A== X-Gm-Message-State: AOJu0Yy5dDwU6gcPgmb14Qo/5p49EBHr+xipxuRrmHGNFkDXyZxpkM7q INp27BDAuacawOD5ZuseHXycWZ4hoawZTPxyrc7tLg== X-Google-Smtp-Source: AGHT+IFRbVWKm09CmY2Tqjzhk751oh+VYO5On7AaytSHvVaEXuE/ETRAOSQR2F4Lhn8TM/pjUKJ8gV9tu89/gkPkdwU= X-Received: by 2002:a50:d089:0:b0:522:cc9c:f5a4 with SMTP id v9-20020a50d089000000b00522cc9cf5a4mr99251edd.4.1694082260577; Thu, 07 Sep 2023 03:24:20 -0700 (PDT) In-Reply-To: <8334zq1mx6.fsf@gnu.org> 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:269637 Archived-At: On Thu, 7 Sept 2023 at 09:07, Eli Zaretskii wrote: > > > From: Xinyang Chen > > Date: Wed, 6 Sep 2023 18:52:14 -0400 > > > > Currently `module_non_local_exit_get` returns pointers to fields > > in emacs_env_private: > > ``` > > if (p->pending_non_local_exit !=3D emacs_funcall_exit_return) > > { > > *symbol =3D &p->non_local_exit_symbol; > > *data =3D &p->non_local_exit_data; > > } > > ``` > > this means that if one tries to: > > ``` > > funcall(...); > > non_local_exit_get(&s1, &d1); > > funcall(...); > > non_local_exit_get(&s2, &d2); > > non_local_exit_signal(s1, d1); > > ``` > > you would signal the second error, instead of the first error (I expect= ed > > this to happen). > > It seems to me that `module_non_local_exit_get` should > > `allocate_emacs_value` instead. > > Philipp, Daniel: any comments? Nice find! We can't use allocate_emacs_value here because non_local_exit_get has to work in OOM situations and can never fail. What we could do here is e.g.: - Document the current behavior, stating that the emacs_value objects returned from non_local_exit_get are ephemeral. I'm not a huge fan of this because it makes non_local_exit_get behave different from all other functions. - Provide an alternative non_local_exit_copy that copies the 2 Lisp_Objects into an opaque buffer supplied by the user (plus a way to determine the buffer size). That way we shift the responsibility of dealing with allocation failures to the user. - Attempt to allocate a new emacs_value, fall back to the current behavior if that fails. I don't really like that option either because it doesn't solve the initial problem in all cases (so users still need to deal with it), but makes both the interface and the implementation more complex. - Crash if we can't allocate memory. That has been rejected in other cases. > > Btw, the non_local_exit_get function is currently not documented in > the ELisp manual; should it be? At least in Emacs 29 I see it documented ("Module Nonlocal" node). -- Google Germany GmbH Erika-Mann-Stra=C3=9Fe 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Liana Sebastian Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Falls Sie diese f=C3=A4lschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, l=C3=B6schen Sie alle Kopien und Anh=C3=A4nge davon und lassen Sie = mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde. This e-mail is confidential. If you received this communication by mistake, please don=E2=80=99t forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.