From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 119382D523 for ; Wed, 16 Oct 2024 19:56:59 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1729101419; b=WQJfaDJtGsKY1uYWwBiu70Ty8myBsC2Q4fVPnAUt8STaK4/iHRNbjTb+k74c46vU8PCL/+P1yW cSStuuF/zzq8QaV2OSPCRANC9ebQhBa0YV8Z5WD2WptWivdr/tttYyISkTf7C51d8502lGS7yc ORTl2PwdTV+i6I2+WT4fx+xcWtq90SscS8nzYFj1yPEaSksflSJbip3IYL24gJ6REicGXaK/4a euaJk5eTof0oiPxGNhdTMDkklLDhVF0BDb7THCGVRHn2Pd9R31aaLdu3pWgheT1oHA3hHOf+FY JKrYJZB5d+ETQINdQ3x+go55NnCcrlQBbm+4XJpChMiDjA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-vs1-f54.google.com) smtp.remote-ip=209.85.217.54; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1729101419; bh=M5jGb/DUbOIy/9HQf/6CGJpTIHYOBdh2BNrmC4gQ2L8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=sawe9kFbOye+8tUUTfNpC3PdHjjsXey6w5DXIvQGEy74BIl6Fffchz6mjib0XLBBu3sW7rrEeZ wFJ+V5lF6rl4l+WMAWeh3H4MIQ3Zo8Eu6/oALsvndsVztWJZPuK5pH/EGDa/xm3IxNTShMVjcB v532cvBFUOT2E98Pf6YngbI2a4yg1Fv1MCngiyS7ieqIMWdKr+B0mnPg3IgNjIlWRMJlEzItK+ vAhqiKAGQR1JFDuY67jBMFS9FnTDZZIphohOHXXQmSvrfG1ZmUB2GlvqvWRW83tTvCyCs56ruI VRmWQMFVxxQeocq9/5664nqG4SH3QsfUTAs3mVwBFJztGQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=jZtP1LFfsshWzC8jo9gE6ObpVA/f+6j34mLlFbM5GkI=; b=Byf8D3bdw3wn9ueLYWbYZBbopF ou4BF+O73VhHJfx+qlzMNny0k7P376Lk31mbOHhlZstkV+Z58+QChAv/+KvaiJcWaRtYXixfryEiT Tuz0W2YTT6FypIN+WRTEG40j0TN0FoAiQHjLhiY6H3LKEMoA5q5HA07AB4tCr7lZcNotoVL/WQcK+ C8ChSxOQWeycI/WBfMQvpZzAw4qdVvDubXTiojV+6M+RXqkQMV2NPQY8+hjNgecvZfayBQHQWM1dL Ljyylp0pYQF13VaQCKFzYNd3w16qB+FkOOXzoHKSjx51LvcDqUCjFlbkKH0Ac9TSa5DvX06v/7pBD nc9ZVfUg==; Received: by zero.zsh.org with local id 1t18GY-000HAK-II; Wed, 16 Oct 2024 17:56:58 +0000 Authentication-Results: zsh.org; iprev=pass (mail-vs1-f54.google.com) smtp.remote-ip=209.85.217.54; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-vs1-f54.google.com ([209.85.217.54]:61519) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1t18GA-000Gr7-Od; Wed, 16 Oct 2024 17:56:36 +0000 Received: by mail-vs1-f54.google.com with SMTP id ada2fe7eead31-4a479773730so5445137.2 for ; Wed, 16 Oct 2024 10:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729101393; x=1729706193; darn=zsh.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=jZtP1LFfsshWzC8jo9gE6ObpVA/f+6j34mLlFbM5GkI=; b=lCdA8KSUAwAlat6Li1dRdFDB7m2Ht85dbyFC/zy4Z/fyD0V57CYXGmtBdc0YSsAElP tFsYnwpWzWloMrZblBdgGcMxVLkEZXq/3/Xtgv2mKjctjLC2tgh9EmdSxHmfQQciVkz7 ypL4fvtxsFddvKfPr+ACd6c8er69XNL/rL3gvFJ+qrRqGxllFHt6FjnZx3WPRziH19yv 0lBstv8N9GM/XXA0uQAn+gee2s1sr/UWy1gCn/Yb9nn39vuODcrsXawwJ0J7E+pcU9MV 4QrUxFx94xrKMhuk48+VVe8eV1sszVyPYE1ocpCWZXhvsyhRDF9INJGVqFk0CLEXQ5Va 9dqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729101393; x=1729706193; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=jZtP1LFfsshWzC8jo9gE6ObpVA/f+6j34mLlFbM5GkI=; b=nwEqIukkiVusp0jFfY8vmbC7isZvHY2QbXu7hYBAXjuZXVlKrZaBqOc2zJb6skJBiC FmL9RTTw/s1ElFnxSrO+SXPYsSK43T4Tzz7Gh/hw/N65ypQhmogiGPK0CIu86TOGdjOJ y2NqHIlopEt2cSS2HfCGFo5IyWlXEz6HUeoBJ0yx7X4UhdN+KtjGqIYeJlA5Xas5IicC Hqu4izd3aO6i7hLnNC8aHTL3WioJwFmeQQX/7Id96wAIURbP5ftHQqvt7WJYPOBN1uYG YbVArJym/RaO6+lHwY/ByaOYzc/V8BOJTZmX2pdxnGAJT2o4KuYdJnYQ2oUus7frwaln V/Bw== X-Gm-Message-State: AOJu0YxIXXhhlad/cIHIUPvKAwNdowdARiNNm/kHMLz+kPXKSYxVBpFb yVV5PGdWgzbmKkgeM1h4BvztfeM3cDWgEhhujCUkF+738jfvBw/az4Rj+4pI/qidEhdf82pzA0U YdyT7KkRDwFRNosjhNSRtOcncPXnoS7FbJzU= X-Google-Smtp-Source: AGHT+IFc0ngD4jivVoNZ3ov2Z5s9lED5ZfONJy7U20eeYmKnY5x2C1OmTCSab3JW5wIfNnZJLXWZP3+2RX6R9jrFAHk= X-Received: by 2002:a05:6102:f0c:b0:4a4:7c8d:2a87 with SMTP id ada2fe7eead31-4a5b599def4mr4213887137.16.1729101393113; Wed, 16 Oct 2024 10:56:33 -0700 (PDT) MIME-Version: 1.0 From: Gilles Date: Wed, 16 Oct 2024 19:55:57 +0200 Message-ID: Subject: [BUG] crash when I unset and redefine a function within itself To: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="000000000000513fd506249bca60" X-Seq: 53145 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --000000000000513fd506249bca60 Content-Type: text/plain; charset="UTF-8" With zsh 5.9 from Ubuntu 24.04 x86_64, or with the latest version from git (383526da422cf1c962d9be7e9e6ac166e226bf2b) compiled locally, the shell segfaults when I run a function that undefines then redefines itself. zsh -c 'foo () { unset -f foo; foo () { echo redefined; }; }; foo' [1] 89793 segmentation fault (core dumped) zsh -c 'foo () { unset -f foo; foo () { echo redefined; }; }; foo' This works with zsh 5.8.1 on Ubuntu 22.04 and older versions. Workaround: if you redefine a function within itself, make sure not to unset it first. This is simplified from real code in my .zshrc that decides on first use whether the command name foo should invoke the external command directly or be a function that wraps around it. -- Gilles --000000000000513fd506249bca60 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
With zsh 5.9 from Ubuntu 24.04 x86_64, or with the latest = version from git (383526da422cf1c962d9be7e9e6ac166e226bf2b) compiled locall= y, the shell segfaults when I run a function that=C2=A0undefines then redef= ines itself.

zsh -c 'foo () { unset -f foo; foo () {= echo redefined; }; }; foo'
[1] =C2=A0 =C2=A089793 segmentation faul= t (core dumped) =C2=A0zsh -c 'foo () { unset -f foo; foo () { echo rede= fined; }; }; foo'

This works with zsh 5.8.1 on= Ubuntu 22.04 and older versions.

Workaround: if y= ou redefine a function within itself, make sure not to unset it first.

This is simplified from real code in my .zshrc that de= cides on first use whether the command name foo should invoke the external = command directly or be a function that wraps around it.

--=C2=A0
Gilles

--000000000000513fd506249bca60--