From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#68690: Segmentation fault building with native-comp Date: Thu, 25 Jan 2024 19:12:21 +0100 Message-ID: References: <87wmryel78.fsf@pub.pink> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_E4AF28AF-DD4F-4C24-82A1-E0560B4E0C28" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34008"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Gerd =?UTF-8?Q?M=C3=B6llmann?= , Eli Zaretskii , jm@pub.pink, 68690@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 25 19:13:16 2024 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 1rT4E0-0008jv-2c for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 25 Jan 2024 19:13:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT4Di-0006Y5-EO; Thu, 25 Jan 2024 13:12:58 -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 1rT4Dg-0006Xf-O2 for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 13:12:56 -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 1rT4Dg-00067F-GA for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 13:12:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rT4Dl-000589-NH for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 13:13:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87wmryel78.fsf@pub.pink> Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Jan 2024 18:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68690 X-GNU-PR-Package: emacs Original-Received: via spool by 68690-submit@debbugs.gnu.org id=B68690.170620636019688 (code B ref 68690); Thu, 25 Jan 2024 18:13:01 +0000 Original-Received: (at 68690) by debbugs.gnu.org; 25 Jan 2024 18:12:40 +0000 Original-Received: from localhost ([127.0.0.1]:49154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rT4DQ-00057U-ED for submit@debbugs.gnu.org; Thu, 25 Jan 2024 13:12:40 -0500 Original-Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:55634) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rT4DL-00057D-3J for 68690@debbugs.gnu.org; Thu, 25 Jan 2024 13:12:38 -0500 Original-Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-5100cb238bcso4610745e87.3 for <68690@debbugs.gnu.org>; Thu, 25 Jan 2024 10:12:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706206343; x=1706811143; darn=debbugs.gnu.org; h=to:cc:date:message-id:subject:mime-version:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=Wdr/3BCg5gVsQO9HRLNYEDqgAbdevH0rCpigXhnmLws=; b=dU9ysl2Lf0yZG6bzGyLdI3w49TJ5ZZeB6BLwBM1Boaa+Kqk6fPQxoKu7tbJDB/xxts O5Cu1zgRi1o8O8YMqv/bnG2ZwafNq5JND/ftfmCKQdON1NyQ0SCJCrCki/iaHtrYlnYq EVN51sUj/U20QJa7EJpLBVqWQYdca9cHFRiNZnN3I2wpSOAKciwXqCLxb8Nyxt+XhbYP J1op4SZKCyIUJr8DIJZj+KXcp3jioSWKsAFLOZiGJJe17U5w8MClrFEIVZX390pp84Dk cci8eIu/tnwFxdCLNfZ3FR7SrkOrU1ovOjdYmgg511wsEJUNw6RJZjdXpMBKw0uSPdQo L8AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706206343; x=1706811143; h=to:cc:date:message-id:subject:mime-version:from:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Wdr/3BCg5gVsQO9HRLNYEDqgAbdevH0rCpigXhnmLws=; b=GIpBJOqT7pzh88G/oeqlAbmt6I4ez2EjMvbDGQC2K+SmqeI8ZZ8DdO/vmSGUHUVTTz kuGIVYkQ5f7ro4a4z03FdnY5htKKHh9Y4DLaMvTNFGfCn9rOFN9TPKgmywKYc/diYxBE czcrAKVzU9o6GBEdJD+53h3fvBXtIMI0Uw9k7u1b7MlEmn3qI8RssAQBtT5Qy+VL2re5 Mf3eSr3tWPzRXuV5KsiBCymfmdKAhgURVaPG5CXGX/snwXU1aocX5zCDtvIv5JbXfYoj PV3ed/4CdSHSi/s0jH2z3q1GwAO7AjPkdVgoI3r1BUhqsV9dXElNB3bnRu6RTlfo58np EBeA== X-Gm-Message-State: AOJu0YwKi2/ck4egXizc643+kFI4YVWAz6tpiqwxxpXrHbXuE3EC4Ont /DSKSXzn+e4T0BYsw+DDDe6kOhqPUNnL3ZhhSFnmZbWqIpcAZGLE X-Google-Smtp-Source: AGHT+IFEJH8xFtx8b2qNO4OA+tl9hSJdStTiFJxfRYYyTLj6P3c6zb5PpvSPCn2rNUR37OUi8BQYXQ== X-Received: by 2002:ac2:4555:0:b0:510:141b:4f94 with SMTP id j21-20020ac24555000000b00510141b4f94mr83968lfm.52.1706206342857; Thu, 25 Jan 2024 10:12:22 -0800 (PST) Original-Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id r21-20020ac25f95000000b005101e485d34sm182410lfe.148.2024.01.25.10.12.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2024 10:12:22 -0800 (PST) X-Mailer: Apple Mail (2.3654.120.0.1.15) 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:278865 Archived-At: --Apple-Mail=_E4AF28AF-DD4F-4C24-82A1-E0560B4E0C28 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > The original DOHASH's comment indeed said it didn't support that > operation, yet the code used DOHASH to implement `maphash`, which = *does* > support such operations, and it used DOHASH in places which perform = such > operations, so I think it's clear we do want to support `puthash` = there. Sorry, my fault -- indeed maphash 'supports' irregular mutation in the = sense that it shouldn't crash or corrupt Emacs if the rules are = violated. I can't reproduce the reported crash(es) on my platform but is = my understanding correct that no other uses of DOHASH caused any = trouble? This patch reverts my last change to Fmaphash and yours to DOHASH. It's = perfectly fine to forego DOHASH in Fmaphash, it's chums with the = hash-table implementation. Assuming that the problems were confined to = Fmaphash, this should be safe to apply. What I certainly would accept is an assertion in DOHASH that verifies = the assumptions but doesn't result in any code at all with checking = disabled. I'll add that if you think it's warranted (and maybe even if = you don't). --Apple-Mail=_E4AF28AF-DD4F-4C24-82A1-E0560B4E0C28 Content-Disposition: attachment; filename=0001-Revert-to-fast-and-simple-DOHASH-keeping-Fmaphash-ro.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Revert-to-fast-and-simple-DOHASH-keeping-Fmaphash-ro.patch" Content-Transfer-Encoding: quoted-printable =46rom=201b44dc419c55cba7e41e8fd8376ebfbae12f04e4=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Thu,=2025=20Jan=202024=2018:56:03=20+0100=0A= Subject:=20[PATCH]=20Revert=20to=20fast=20and=20simple=20DOHASH=20= keeping=20Fmaphash=20robust=0A=20(bug#68690)=0A=0A`maphash`=20mustn't=20= crash=20if=20the=20supplied=20function=20does=20odd=20things=20but=0A= that=20doesn't=20mean=20we=20have=20to=20make=20DOHASH=20more=20= expensive.=0AThis=20change=20essentially=20reverts=20ad004f10f3=20and=20= the=20Fmaphash=20part=20of=0Afec87a4b36.=0A=0A*=20src/lisp.h=20(DOHASH):=20= Go=20back=20to=20fast=20design=20with=20more=20rules.=0A*=20src/fns.c=20= (Fmaphash):=20Ditch=20DOHASH=20in=20favour=20of=20explicit=20loop.=0A---=0A= =20src/fns.c=20=20|=2011=20+++++++++--=0A=20src/lisp.h=20|=2038=20= ++++++++++++++------------------------=0A=202=20files=20changed,=2023=20= insertions(+),=2026=20deletions(-)=0A=0Adiff=20--git=20a/src/fns.c=20= b/src/fns.c=0Aindex=20859df6748f7..519d85df288=20100644=0A---=20= a/src/fns.c=0A+++=20b/src/fns.c=0A@@=20-5662,8=20+5662,15=20@@=20DEFUN=20= ("maphash",=20Fmaphash,=20Smaphash,=202,=202,=200,=0A=20=20=20= (Lisp_Object=20function,=20Lisp_Object=20table)=0A=20{=0A=20=20=20struct=20= Lisp_Hash_Table=20*h=20=3D=20check_hash_table=20(table);=0A-=20=20DOHASH=20= (h,=20k,=20v)=0A-=20=20=20=20call2=20(function,=20k,=20v);=0A+=20=20/*=20= We=20can't=20use=20DOHASH=20here=20since=20FUNCTION=20may=20violate=20= the=20rules=20and=0A+=20=20=20=20=20we=20shouldn't=20crash=20as=20a=20= result=20(although=20the=20effects=20are=0A+=20=20=20=20=20= unpredictable).=20=20*/=0A+=20=20for=20(ptrdiff_t=20i=20=3D=200;=20i=20<=20= HASH_TABLE_SIZE=20(h);=20i++)=0A+=20=20=20=20{=0A+=20=20=20=20=20=20= Lisp_Object=20k=20=3D=20HASH_KEY=20(h,=20i);=0A+=20=20=20=20=20=20if=20= (!hash_unused_entry_key_p=20(k))=0A+=20=20=20=20=20=20=20=20call2=20= (function,=20k,=20HASH_VALUE=20(h,=20i));=0A+=20=20=20=20}=0A=20=20=20= return=20Qnil;=0A=20}=0A=20=0Adiff=20--git=20a/src/lisp.h=20b/src/lisp.h=0A= index=20d07d9d14e2f..f822417ffb1=20100644=0A---=20a/src/lisp.h=0A+++=20= b/src/lisp.h=0A@@=20-2604,30=20+2604,20=20@@=20hash_from_key=20(struct=20= Lisp_Hash_Table=20*h,=20Lisp_Object=20key)=0A=20}=0A=20=0A=20/*=20= Iterate=20K=20and=20V=20as=20key=20and=20value=20of=20valid=20entries=20= in=20hash=20table=20H.=0A-=20=20=20The=20body=20may=20mutate=20the=20= hash-table.=20=20*/=0A-#define=20DOHASH(h,=20k,=20v)=09=09=09=09=09=09=09= =20\=0A-=20=20for=20(Lisp_Object=20*dohash_##k##_##v##_base=20=3D=20= (h)->key_and_value,=09=20\=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20*dohash_##k##_##v##_kv=20=20=20=3D=20= dohash_##k##_##v##_base,=09=20\=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20*dohash_##k##_##v##_end=20=20=3D=20= dohash_##k##_##v##_base=09=20\=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20+=202=20*=20HASH_TABLE_SIZE=20(h),=20\=0A-=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20k,=20v;=09=09=09=09=09=09= =20\=0A-=20=20=20=20=20=20=20dohash_##k##_##v##_kv=20<=20= dohash_##k##_##v##_end=09=09=09=20\=0A-=20=20=20=20=20=20=20&&=20= (dohash_##k##_##v##_base=20=3D=3D=20(h)->key_and_value=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20\=0A-=20=20=20=20=20=20=20=20=20=20=20/*=20= The=20`key_and_value`=20table=20has=20been=20reallocated!=20=20*/=20=20=20= =20=20=20=20=20\=0A-=20=20=20=20=20=20=20=20=20=20=20||=20= (dohash_##k##_##v##_kv=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20\=0A-=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=3D=20= (dohash_##k##_##v##_kv=20-=20dohash_##k##_##v##_base)=09=20\=0A-=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20+=20= (h)->key_and_value,=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20\=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20dohash_##k##_##v##_base=20=3D=20(h)->key_and_value,=20=20= =20=20=20=20=20=20=20=20=20=20=20\=0A-=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20dohash_##k##_##v##_end=20=20=3D=20dohash_##k##_##v##_base=09=20= \=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20+=202=20*=20= HASH_TABLE_SIZE=20(h),=20=20=20=20=20=20\=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20/*=20Check=20again,=20in=20case=20the=20table=20has=20= shrunk.=20=20*/=20=20=20=20=20=20=20=20=20\=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20dohash_##k##_##v##_kv=20<=20dohash_##k##_##v##_end))=20= =20=20=20=20=20=20=20=20=20\=0A-=20=20=20=20=20=20=20&&=20(k=20=3D=20= dohash_##k##_##v##_kv[0],=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20\=0A-=20=20=20=20=20=20= =20=20=20=20=20v=20=3D=20dohash_##k##_##v##_kv[1],=20/*maybe=20unused*/=20= (void)v,=20=20=20=20=20=20=20\=0A-=20=20=20=20=20=20=20=20=20=20=20= true);=09=09=09=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20\=0A-=20=20=20=20=20=20=20=20= dohash_##k##_##v##_kv=20+=3D=202)=09=09=09=09=20=20=20=20=20=20=20=20=20= \=0A-=20=20=20=20if=20(hash_unused_entry_key_p=20(k))=09=09=09=09=20=20=20= =20=20=20=20=20=20\=0A-=20=20=20=20=20=20;=09=09=09=09=09=09=09=09=20=20=20= =20=20=20=20=20=20\=0A+=20=20=20The=20body=20may=20remove=20the=20= current=20entry=20or=20alter=20its=20value=20slot,=20but=20not=0A+=20=20=20= mutate=20TABLE=20in=20any=20other=20way.=20=20*/=0A+#define=20DOHASH(h,=20= k,=20v)=09=09=09=09=09=09=09\=0A+=20=20for=20(Lisp_Object=20= *dohash_##k##_##v##_kv=20=3D=20(h)->key_and_value,=09=09\=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20*dohash_##k##_##v##_end=20=3D= =20dohash_##k##_##v##_kv=09\=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20+=202=20*=20HASH_TABLE_SIZE=20(h),=09\=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20k,=20v;=09=09=09=09=09=09\=0A+=20= =20=20=20=20=20=20dohash_##k##_##v##_kv=20<=20dohash_##k##_##v##_end=09=09= =09\=0A+=20=20=20=20=20=20=20&&=20(k=20=3D=20dohash_##k##_##v##_kv[0],=09= =09=09=09\=0A+=20=20=20=20=20=20=20=20=20=20=20v=20=3D=20= dohash_##k##_##v##_kv[1],=20/*maybe=20unsed*/=20(void)v,=20=20=20=20=20=20= =20\=0A+=20=20=20=20=20=20=20=20=20=20=20true);=09=09=09=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20\=0A+=20=20=20=20=20=20=20=20dohash_##k##_##v##_kv=20+=3D=202)=09=09=09= =09=09\=0A+=20=20=20=20if=20(hash_unused_entry_key_p=20(k))=09=09=09=09=09= \=0A+=20=20=20=20=20=20;=09=09=09=09=09=09=09=09=09\=0A=20=20=20=20=20= else=0A=20=0A=20=0A--=20=0A2.32.0=20(Apple=20Git-132)=0A=0A= --Apple-Mail=_E4AF28AF-DD4F-4C24-82A1-E0560B4E0C28--