From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#63752: 28.2; GCC 13.1 breaks Emacs subprocess handling when built with -D_FORTIFY_SOURCE Date: Sat, 01 Jul 2023 09:40:09 +0300 Message-ID: <837crkrv7a.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10443"; mail-complaints-to="usenet@ciao.gmane.io" Cc: svraka.andras@gmail.com, 63752@debbugs.gnu.org To: Cyril Arnould Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 01 08:40:29 2023 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 1qFUHV-0002Xw-4d for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 Jul 2023 08:40:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFUH5-0004fJ-Oi; Sat, 01 Jul 2023 02:40:03 -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 1qFUH4-0004et-52 for bug-gnu-emacs@gnu.org; Sat, 01 Jul 2023 02:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFUH3-0001Kx-SV for bug-gnu-emacs@gnu.org; Sat, 01 Jul 2023 02:40:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qFUH3-0008LQ-Nm for bug-gnu-emacs@gnu.org; Sat, 01 Jul 2023 02:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 01 Jul 2023 06:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63752 X-GNU-PR-Package: emacs Original-Received: via spool by 63752-submit@debbugs.gnu.org id=B63752.168819359032053 (code B ref 63752); Sat, 01 Jul 2023 06:40:01 +0000 Original-Received: (at 63752) by debbugs.gnu.org; 1 Jul 2023 06:39:50 +0000 Original-Received: from localhost ([127.0.0.1]:56268 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qFUGq-0008Kt-HV for submit@debbugs.gnu.org; Sat, 01 Jul 2023 02:39:50 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:45016) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qFUGn-0008Kf-Fa for 63752@debbugs.gnu.org; Sat, 01 Jul 2023 02:39:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFUGh-0001GX-Gz; Sat, 01 Jul 2023 02:39:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=GHAZKPdwOdJe1NBI32TpjiVWMWQZLLVkw+4UILFid28=; b=V6ae8dYqTCPy4+Ok1gr0 egLTzOehK9I24ploHmXArTToalc+D+mA1Uy400yGYLQZ9ykWaLC40Ill15Xix8+PmWX1RKJlf/+Yo pjPIM5VFxew0M0QkdRtMO2gxcjizhIu7SVuohzlT2zG9weu2vR9gJlZSWAiIuOOyEfCFnRFUjwsFY LQXuAntlajEN5o83GgQMNoPE1euhgNP0aFY6UdxmXfTyCTGBxVXWqvpkBB7XJ+MpoyhkWAagTPSCQ AbLM/OhGByLy4JjVJ/KlSfvR49aSD9yZaAlf79XPESbUXTfMrQ9tV37QCw+4OPpQQuJxgHBTiVfHi PerY/dJJZTHBNQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFUGh-0005ii-01; Sat, 01 Jul 2023 02:39:39 -0400 In-Reply-To: (message from Cyril Arnould on Fri, 30 Jun 2023 22:41:26 +0000) 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:264357 Archived-At: > From: Cyril Arnould > CC: "63752@debbugs.gnu.org" <63752@debbugs.gnu.org>, > András Svraka > Date: Fri, 30 Jun 2023 22:41:26 +0000 > > I've found that I can narrow it down similar to bug #63365: As long as I > don't compile src/sysdep.c with -D_FORTIFY_SOURCE, the resulting > binaries seem to behave normally. Does that maybe suggest an upstream > problem? I compiled it as follows: > > git clean -xdf > git checkout emacs-28.2 > ./autogen.sh > ./configure > cd src > make sysdep.o CFLAGS='-g3 -O2 -gdwarf-2 -Wp,-D_FORTIFY_SOURCE=2' > make sysdep.o -W sysdep.c > cd .. > make CFLAGS='-g3 -O2 -gdwarf-2 -Wp,-D_FORTIFY_SOURCE=2' > > I've attached the objects as well as their dumps in case anyone wants to > take a look. Thanks, but the differences are too large to figure out what causes this. It sounds like -D_FORTIFY_SOURCE=2 wraps and/or replaces many library functions with special variants, and effect of that is unclear, because the implementation of those wrappers is elsewhere (probably in some library linked into the executable under that option?). E.g., by just looking at the diffs, it sounds like the -D_FORTIFY_SOURCE=2 code doesn't call 'open' to open the null device?? Since you've already established sysdep.c alone is the culprit, I suggest to narrow this. Create a separate file sysdep1.c, move to it the first portion of sysdep.c which includes everything before serial_open, and build Emacs with these two parts (you'd need to add sysdep1.o to base_obj in src/Makefile). Once you have such an Emacs successfully built and reproduce the problem, rebuild by compiling sysdep1.c without -D_FORTIFY_SOURCE=2, and see if the problem goes away. If it does, bisect sysdep1.c by moving parts of it back to sysdep.c, until you identify the smallest part of sysdep.c that needs to be compiled with -D_FORTIFY_SOURCE=2 to reproduce the problem. Then we will have to examine the effect of -D_FORTIFY_SOURCE=2 on that smallest part, and see if we can figure this out. This is a lot of work, so kudos if you are motivated to go ahead and do it. From my POV, the -D_FORTIFY_SOURCE=2 build is currently problematic on Windows and therefore not supported by the upstream project. (IMNSHO, it is also wrong to use this in production builds of programs such as Emacs, but that's me, and I know others disagree.) My advice to MSYS2 folks at this time is to stop building Emacs that way until the problem is resolved.