From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?=C3=93scar?= Fuentes Newsgroups: gmane.emacs.bugs Subject: bug#73444: 30.0.50; mingw-w64: Emacs uses CRT's `read` when _FORTIFY_SOURCE > 0 Date: Tue, 24 Sep 2024 00:15:11 +0200 Message-ID: <87r09axbio.fsf@telefonica.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11678"; mail-complaints-to="usenet@ciao.gmane.io" To: 73444@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 24 00:15:58 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 1ssrLa-0002tN-KU for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Sep 2024 00:15:58 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ssrLM-0001Ai-Sx; Mon, 23 Sep 2024 18:15:44 -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 1ssrLI-0001AP-Hv for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 18:15:40 -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 1ssrLI-0001lf-6j for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 18:15:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=G8GAGaHJEOOhZkZZls1lm0p21zpVFxq9KQfzkIeB43I=; b=jWugaXuYKo7u2hOqYY43ukabdWmu84dDGdZPCdrA0vLrE3mqnbALfzdsi//JxtZ84xxyC8eLHw5FY97y0TihzHEUbN52irRJCwx5GCmNI8Cw5ydTAw4FrF2y0fQVpt65zUoJl8ARDRnYmjPGNUlb/lNHUrTYbg6UyMgFG0x8vRMzqM0Th7cDEYPAF8TTbjMa7+u2oFrUiOkziYp+qbAt5tyhOl5C8nKXInd5v704yJ1I233UprnFWBT4TqI+JdppgyjS8t165LIB2oK+relQGBaAzMF6/7d76cjVZUj/qOjcW4z/f4FhkEnQjMx6hJ3IQY7DI/WtkiHPaXgI02QzGA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ssrLe-0001es-JB for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 18:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 23 Sep 2024 22:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 73444 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17271297536353 (code B ref -1); Mon, 23 Sep 2024 22:16:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Sep 2024 22:15:53 +0000 Original-Received: from localhost ([127.0.0.1]:44844 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ssrLV-0001eP-Bk for submit@debbugs.gnu.org; Mon, 23 Sep 2024 18:15:53 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:34990) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ssrLT-0001eI-Iq for submit@debbugs.gnu.org; Mon, 23 Sep 2024 18:15:52 -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 1ssrL5-00019p-Q2 for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 18:15:27 -0400 Original-Received: from relayout02.e.movistar.es ([86.109.101.202] helo=relayout02-redir.e.movistar.es) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ssrL2-0001kW-My for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 18:15:27 -0400 Original-Received: from sky (132.red-81-39-22.dynamicip.rima-tde.net [81.39.22.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout02.e.movistar.es (Postfix) with ESMTPSA id 4XCHNw14n0zdZRN for ; Tue, 24 Sep 2024 00:15:11 +0200 (CEST) X-TnetOut-Country: IP: 81.39.22.132 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout02 X-TnetOut-MsgID: 4XCHNw14n0zdZRN.A2540 X-TnetOut-SpamCheck: no es spam, clean X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1727734514.24166@3SgkCIFAZy2NKYxyL+oqIQ Received-SPF: softfail client-ip=86.109.101.202; envelope-from=ofv@wanadoo.es; helo=relayout02-redir.e.movistar.es X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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:292293 Archived-At: On Onssee When the macro _FORTIFY_SOURCE > 0, mingw-64 provides an inline definition of `read` on io.h: __mingw_bos_extern_ovr int read(int __fh, void * __dst, unsigned int __n) { return _read(__fh, __dst, __n); } *Before* #including io.h, ms-w32.h does #define read sys_read so the inline definition of read above ends like this: int sys_read(int __fh, void * __dst, unsigned int __n) { return _read(__fh, __dst, __n); } As the result of this, the above definition is used instead of Emacs' definition of sys_read. The resulting Emacs is unusable due to problems handling subprocesses. A hack that avoids this consists on doing something like: #define read dummy_read // etc #include // etc #undef read #define read sys_read int sys_read (int, char *, unsigned int); or simpler but untested: #define _read sys_read // etc #include // etc Either way it is necessary to condition the hack on the value of _FORTIFY_SOURCE. More generally, the way Emacs/NT overrides the CRT functions is susceptible to break anytime upstream does something like, this case, adding an inline definition, or some other unanticipated change. AFAIK the C standard says that precisely what Emacs is doing incurs on undefined behavior. Any ideas about how to future-proof the solution for this problem? BTW, the initial bug report for this was in March 2023 and only today was succesfully analyzed (1) This gives an idea of how problematic this practice of redefining standard functions can be. 1. https://github.com/msys2/MINGW-packages/issues/17343#issuecomment-2368903501