From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74966: 31.0.50; Crash report (using igc on macOS) Date: Fri, 20 Dec 2024 16:40:52 +0000 Message-ID: <87ikrejok5.fsf@protonmail.com> References: <86a5cqkc2g.fsf@gnu.org> <86o716ah09.fsf@gnu.org> Reply-To: Pip Cet 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="7672"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Gerd =?UTF-8?Q?M=C3=B6llmann?= , spd@toadstyle.org, Eli Zaretskii , acorallo@gnu.org, 74966@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 20 17:42:26 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 1tOg53-0001sM-DK for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 20 Dec 2024 17:42:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOg4i-0003wv-7E; Fri, 20 Dec 2024 11:42:04 -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 1tOg4g-0003wn-Qw for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2024 11:42:03 -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 1tOg4g-0007JW-Hv for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2024 11:42:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:From:Date:To:Subject; bh=JkOp1hgInSCdfjxj0BhFJqW5Q5OWqxMRSCRp+E67KcI=; b=QY5fFHTEj9ieTBmuieack57rLNmcqBdZJcQDWv31GyxAKxm4zM6On3ryDSt3lfHjkLH1lPKmF9vOdn7ahNe3hcV+z3cqR1YFMEXI3VMGCFQUnWDoW0OH4nHG/Fc1q9FYQReyndtBgVG2H6bvB0NCnXjzAvQBifX4CGTOsyXgVwVcvN7CmB/3vYdKr0OjzAS0j21/+QuyJBBcpJ6SUikI8wxn3bs8G18i2kd2+7O3qv1maZr6+SdxACe16rcv/Bc7iBqE7C5PgK/zI5kSfIoxNxAPn35cb3Pbpi/lxBQ8G+kGMZK2CPDqRB6IrbrMSuSDKzFOVHt+fhHhU/IXrgknuA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tOg4g-00021N-71 for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2024 11:42:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Dec 2024 16:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74966 X-GNU-PR-Package: emacs Original-Received: via spool by 74966-submit@debbugs.gnu.org id=B74966.17347128647692 (code B ref 74966); Fri, 20 Dec 2024 16:42:02 +0000 Original-Received: (at 74966) by debbugs.gnu.org; 20 Dec 2024 16:41:04 +0000 Original-Received: from localhost ([127.0.0.1]:43791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOg3k-0001zz-11 for submit@debbugs.gnu.org; Fri, 20 Dec 2024 11:41:04 -0500 Original-Received: from mail-4316.protonmail.ch ([185.70.43.16]:39319) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOg3g-0001zM-RM for 74966@debbugs.gnu.org; Fri, 20 Dec 2024 11:41:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1734712854; x=1734972054; bh=JkOp1hgInSCdfjxj0BhFJqW5Q5OWqxMRSCRp+E67KcI=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=Oaxd1HFtqC3BbXwWuI/xfB/VYSXVGhR2Yr9RcZhZ0Xe9+q1Z/gHe9+xLnmIfKvfkM 0bbqLaMcxv6JTeXFPA5mG+hqfwZVgSuP47dF7tFhC7J0xbNEC10Hju6VkqNtpKk6cd xyOJ8VYuUaA0NWiOFthfXLibyTEQp88whc2aJNKkB6CRvAeEP2TPwK4WassLANzLff FU2VkH4VXLwLhLSIEUs47/yGKiWs3eWjHFtefVu8B4L6Y9WXbyQUPCTsGFI7J8HhEj BX0pSKWPFxjZ2OPAwa8Fu4XwHLSUhisvNv0nloUaXhQrioPmXlE7Y4ZQtlDon9hAFN sZSiFcBy0uM+Q== In-Reply-To: Feedback-ID: 112775352:user:proton X-Pm-Message-ID: ce20a7dcd4768cc08ce7be8b8d1de2e157f88682 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:297460 Archived-At: Pip Cet writes: > "Stefan Monnier" writes: > >>>> Maybe the problem is in store_doc_string (doc.c:469 here), not sure. >>>> That function does >>>> >>>> if (SUBRP (fun)) >>>> XSUBR (fun)->doc =3D offset; >> >> Sounds right. >> >>> That seems to be the cause, indeed. When I >>> >>> 1 file changed, 4 insertions(+), 1 deletion(-) >>> src/doc.c | 5 ++++- >>> >>> modified src/doc.c >>> @@ -479,7 +479,10 @@ store_function_docstring (Lisp_Object obj, EMACS_I= NT offset) >>> fun =3D XCDR (fun); >>> /* Lisp_Subrs have a slot for it. */ >>> if (SUBRP (fun)) >>> - XSUBR (fun)->doc =3D offset; >>> + { >>> + if (!NATIVE_COMP_FUNCTIONP (fun)) >>> +=09XSUBR (fun)->doc =3D offset; >>> + } >>> else if (CLOSUREP (fun)) >>> { >>> /* This bytecode object must have a slot for the docstring, sinc= e >>> >>> I don't get the assert anymore. >> >> `offset` here should be fixnum that gives the position of this docstring >> in the DOC file. And FUN should be a function for which we found > > Yes, but the nativecomp code assumes ->doc is an index into a > nativecomp'd subr's constant vector. So we overwrite it with a docfile > index, access an out-of-bounds index and crash. > > I think the best thing to do is to use separate fields for the "offset" > doc and the "index" doc; or at least, the second best thing, after > removing the entire docfile hack. > > I've got a patch to do that, but I'm still testing... I meant this patch, which splits "doc" into "doc_index" and "doc_offset". It'd probably be better to use a Lisp_Object here, which can be either a fixnum (index into etc/DOC) or a string (the doc string specified in some other manner). And maybe we can drop the docfile index thing entirely at some point soon? Pip diff --git a/src/comp.c b/src/comp.c index 8b38adec252..0b378463c16 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5352,7 +5352,7 @@ native_function_doc (Lisp_Object function) if (!VECTORP (cu->data_fdoc_v)) xsignal2 (Qnative_lisp_file_inconsistent, cu->file, =09 build_string ("missing documentation vector")); - return AREF (cu->data_fdoc_v, XSUBR (function)->doc); + return AREF (cu->data_fdoc_v, XSUBR (function)->doc_index); } =20 static Lisp_Object @@ -5393,8 +5393,9 @@ make_subr (Lisp_Object symbol_name, Lisp_Object minar= g, Lisp_Object maxarg, x->s.symbol_name =3D xstrdup (SSDATA (symbol_name)); x->s.intspec.native =3D intspec; x->s.command_modes =3D command_modes; - x->s.doc =3D XFIXNUM (doc_idx); + x->s.doc_offset =3D 0; #ifdef HAVE_NATIVE_COMP + x->s.doc_index =3D XFIXNUM (doc_idx); x->s.native_comp_u =3D comp_u; x->s.native_c_name =3D xstrdup (SSDATA (c_name)); x->s.type =3D type; diff --git a/src/doc.c b/src/doc.c index 6f74a999366..510034c225d 100644 --- a/src/doc.c +++ b/src/doc.c @@ -391,13 +391,15 @@ DEFUN ("internal-subr-documentation", Fsubr_documenta= tion, Ssubr_documentation, doc: /* Return the raw documentation info of a C primitive. */) (Lisp_Object function) { + if (SUBRP (function) && XSUBR (function)->doc_offset) + return make_fixnum (XSUBR (function)->doc_offset); #ifdef HAVE_NATIVE_COMP if (!NILP (Fnative_comp_function_p (function))) return native_function_doc (function); else #endif if (SUBRP (function)) - return make_fixnum (XSUBR (function)->doc); + return make_fixnum (XSUBR (function)->doc_offset); #ifdef HAVE_MODULES else if (MODULE_FUNCTIONP (function)) return module_function_documentation (XMODULE_FUNCTION (function)); @@ -479,7 +481,7 @@ store_function_docstring (Lisp_Object obj, EMACS_INT of= fset) fun =3D XCDR (fun); /* Lisp_Subrs have a slot for it. */ if (SUBRP (fun)) - XSUBR (fun)->doc =3D offset; + XSUBR (fun)->doc_offset =3D offset; else if (CLOSUREP (fun)) { /* This bytecode object must have a slot for the docstring, since diff --git a/src/lisp.h b/src/lisp.h index 33a9269b305..aa7d9c4edac 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2184,8 +2184,9 @@ CHAR_TABLE_SET (Lisp_Object ct, int idx, Lisp_Object = val) Lisp_Object native; } intspec; Lisp_Object command_modes; - EMACS_INT doc; + EMACS_INT doc_offset; #ifdef HAVE_NATIVE_COMP + EMACS_INT doc_index; Lisp_Object native_comp_u; char *native_c_name; Lisp_Object lambda_list; diff --git a/src/pdumper.c b/src/pdumper.c index d45bbc84bba..51a926591d3 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2964,7 +2964,7 @@ dump_bool_vector (struct dump_context *ctx, const str= uct Lisp_Vector *v) static dump_off dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr) { -#if CHECK_STRUCTS && !defined (HASH_Lisp_Subr_20B7443AD7) +#if CHECK_STRUCTS && !defined (HASH_Lisp_Subr_B6C57C930B) # error "Lisp_Subr changed. See CHECK_STRUCTS comment in config.h." #endif struct Lisp_Subr out; @@ -2996,8 +2996,9 @@ dump_subr (struct dump_context *ctx, const struct Lis= p_Subr *subr) dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec.string); dump_field_emacs_ptr (ctx, &out, subr, &subr->command_modes); } - DUMP_FIELD_COPY (&out, subr, doc); + DUMP_FIELD_COPY (&out, subr, doc_offset); #ifdef HAVE_NATIVE_COMP + DUMP_FIELD_COPY (&out, subr, doc_index); dump_field_lv (ctx, &out, subr, &subr->native_comp_u, WEIGHT_NORMAL); if (!NILP (subr->native_comp_u)) dump_field_fixup_later (ctx, &out, subr, &subr->native_c_name);