From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24095 invoked from network); 3 May 2023 15:36:19 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 May 2023 15:36:19 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1683128179; b=l/YeMZ4qtmbPIdgXfql8VPihMRJxSp8UGcii4PtI+4GLSDP13v7g+L3gd65k3pGjNvrrzaj3IT lZTMRf+CPXPmbL7EegizqyMIpzzQowU9DogISR8JE1t/u6BXZ5ywYCmoPv6d+LfvLM3M7yFh7g XGcfOh/GT3zaGx8gWH1ZePC6aw5iTF1RpJp/KlJRnXp7MFuGP7OruZzrmZ0mK+Sr/dvzoOY6bK TZZVvhvPzdj5Qvd6OxdUTArWHCdMet3Dy92rsV3SG4Kr2/YBzaOnD4GBA1m0EEF7iFNFfxqVwp pmcdhpMzOceXZnrklIL5/64dbWvA5uJnkPxRSjm5xHR5+w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f178.google.com) smtp.remote-ip=209.85.208.178; dkim=pass header.d=gmail.com header.s=20221208 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=1683128179; bh=gKTtiSsZRwq7+GBatNQFprrMwjvhXKfS1JeGjaxUd24=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=Xo5utfG9BLFI55rc4ADJf0mX9yw+cfg0WCG6/keQG2BBr1FikIkGld8zuPWCfv1422kQawCZ78 6aLBEdAF8V7OVrfmutkj2TjDEOnA1dhvAGmWhY2oDe3cavjN+EH8sNVbik7/fVMFu2nfI2J2ZQ ADpETiCGGuZRzcbtktRejrYQg6a++2gs481S0y4XhJ4w1iYRuk+uW4p1wo4kEsUsZERYaOXILy 57IZTOoAE8ZtehXuOLU5m/mEtyUhimB+xsAsa5aFIjlkJzwkaHb7ZNhLGyud2Shl6UWkWTmZd3 oE67EifBFQP5363Q4e693qj+WxntnhIcH/SE7OzxtUwVfw==; 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-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=/rGRv0DU7ZLZyH3g0HccYku2yGihehVLlxR3DGNJ9PI=; b=koNsI0s1kmzsnJOiIYeRLf48d8 2wnBG2ts8pZbLepukFfQF2oxqwLeQjPF585+iHOpjMQZNS0pGPH1yxtii1+df//3p7wsy0rZTo20B GUuIfsYW1W2zn4LnWAhguIerUVVs7rGwfBEid0BlQikZhF8hRRD03BM5aGHkLY0QSQa2l3YN6s/rU cmZNNHo2Ok6mnZ0neVDuKbPsal3OCvslGpoBmUekM9P8NhSZ8MnoIqf2IvaTcUswAdyoJGTK5d8sk e+nkjnp+YflAenqX71lxi1v51uils2CrHfWLtTTiDdj7a1AC69UqZmBXRhbffBbjK11xg9xOPc9jD jmV2HCXA==; Received: by zero.zsh.org with local id 1puEWg-000Gan-IN; Wed, 03 May 2023 15:36:18 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f178.google.com) smtp.remote-ip=209.85.208.178; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f178.google.com ([209.85.208.178]:54366) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1puEW3-000GGa-8k; Wed, 03 May 2023 15:35:42 +0000 Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2a7b02615f1so55599181fa.0 for ; Wed, 03 May 2023 08:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683128138; x=1685720138; 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=/rGRv0DU7ZLZyH3g0HccYku2yGihehVLlxR3DGNJ9PI=; b=TcXZoWl0Ok5Ej5rl5i6KuldZnJvpOza/d5xpCrOtOWxHtfvuUkQVMplVwqC16Rz07Y y4Or11P98gANbmwMwIaXs5oLrO+kK7TzFk6iKTLhz/Xw0EnTVv73n49Aw7wJczezxliB CtwEtsXlBsreZgJezh/Nh6k+vtMv1ZdlDRslGXPon/NXS73dvZTIWcg5pVKitpcwDsRn JgXrR+zq7zEseTjJNmLEpYC4l3b+4el809DHTcw0i8JXDozKlLz5SCQSMpJjxo7mz0VW Zt/b3uIEYbsT4BpGdWU3Q3I+H2HrOSn2VAiZZEMoXbWwZj3FBRceMxlYT1M7dbJP8KwJ xziQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683128138; x=1685720138; 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=/rGRv0DU7ZLZyH3g0HccYku2yGihehVLlxR3DGNJ9PI=; b=ReV4FpfsZgg88n0EXFaHnDbMddFwa5wibHhcV4emr2BIFdRhV6OY19fzDJayxYnDe5 jjSlvoEu8O7TeD4sVQC2hNMssgxsjT1BOzQFt7cJ+Z/tCgQoOuBPVGvsrddC/EXBlcvG RQW68uA7By4QJIrhINerALjCLUPAIaH6v44L+7yBFWRTGS22i6dBkkYAu7LdYFHx1MMN c0txSpczokI6bOxY53QmuS+tdZ1ZjXsEOXQa95DP+cFA3ytt2wmwWXTxvf2Xi2QxZ97u W1whCqKEgjzsCsFUXtqWJ7V5LQtDv8lnnJX9nMNoV3lnC4Hebr/VHkWnOEOsCcaT9IAC mlDw== X-Gm-Message-State: AC+VfDxHTf0x1zPhQdk1aBg/Dk5xTLMfrQ4SvKCzfgT5e3EaytZS5u54 KbmcZTkNU4Fi8MCYUxRvdPq9XCjiZJKmWway0xLXMvVM4Ck= X-Google-Smtp-Source: ACHHUZ50yuww5GtT9JVysLbPxTEY2m1YL2nTPBpZwYI11CJj9SCV4eByV4mieC7+QR7k+ZPB+LG2ZYmX2ReQn+wJ680= X-Received: by 2002:a2e:8659:0:b0:2a8:a573:aed5 with SMTP id i25-20020a2e8659000000b002a8a573aed5mr140809ljj.27.1683128137953; Wed, 03 May 2023 08:35:37 -0700 (PDT) MIME-Version: 1.0 References: <886115150.3264962.1682430985767@mail.virginmedia.com> <384683842.2892075.1682682065470@mail.virginmedia.com> <1209713483.9390210.1682691745248@mail.virginmedia.com> <9a4279398cabea525bb77662418ad536be7770bc.camel@ntlworld.com> In-Reply-To: <9a4279398cabea525bb77662418ad536be7770bc.camel@ntlworld.com> From: Sebastian Gniazdowski Date: Wed, 3 May 2023 15:35:11 +0000 Message-ID: Subject: Re: [BUG] sigsegv To: Peter Stephenson Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 51703 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: The error occurs with patch. I've played around in gdb: (gdb) p (int)(e-hstr) $65 =3D -31903 This should be positive =E2=80=93 e points to a \0 inserted in hstr. That's why printing e shows unexpected values. How come wend became negative? On Sun, 30 Apr 2023 at 17:31, Peter Stephenson wrote: > > On Sat, 2023-04-29 at 10:52 +0000, Sebastian Gniazdowski wrote: > > It says "incomplete sequence \339" although egrep $'\330' ~/.zhistory > > doesn't return anything=E2=80=A6 > > So it looks like this is probably confusion over bad or incomplete > multibyte characters again. > > Rather than bufferwords() --- I think that's not relevant at this point > --- this could be the code that reads a history line back into the buffer > and divides it into words getting confused. This is different from > the code that adds to a history line when it's first generated and > likely to be less accurate --- and also fits better with the > reproducibility of this problem. > > Anyway, given there's no single place where the line originates, > and given that we're probably not going to be able to turn it into > a proper line if the there's not a complete character sequence, > safety at the point in question is probably the best we've got. > > See if this helps. > > pws > > diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c > index 96a211c69..2067f5bab 100644 > --- a/Src/Modules/parameter.c > +++ b/Src/Modules/parameter.c > @@ -1233,9 +1233,16 @@ histwgetfn(UNUSED(Param pm)) > pushnode(l, getdata(n)); > > while (he) { > + char *hstr =3D he->node.nam; > + int len =3D strlen(hstr); > for (iw =3D he->nwords - 1; iw >=3D 0; iw--) { > - h =3D he->node.nam + he->words[iw * 2]; > - e =3D he->node.nam + he->words[iw * 2 + 1]; > + int wbegin =3D he->words[iw * 2]; > + int wend =3D he->words[iw * 2 + 1]; > + > + if (wbegin >=3D len || wend > len) > + break; > + h =3D hstr + wbegin; > + e =3D hstr + wend; > sav =3D *e; > *e =3D '\0'; > addlinknode(l, dupstring(h)); > > --=20 Best regards, Sebastian Gniazdowski