From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A29393857C5D; Fri, 8 Oct 2021 07:58:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A29393857C5D From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/56659] Segfault due to missing libcpp error handler for "gfortran -cpp" Date: Fri, 08 Oct 2021 07:58:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.8.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2021 07:58:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D56659 --- Comment #10 from Tobias Burnus --- (In reply to Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez from comment #9) > (In reply to Tobias Burnus from comment #8) > > f951: Warning: Include directory =E2=80=98foo/bar/=E2=80=99: Permissi= on denied > > : Error: foo/bar: Permission denied > > (The =20 > > Are you sure the Error is produced *after* entering the file (by entering= I > mean pushing the file into the include stack and thus updating the > line-map). I was too brief. It occurs between the two. The full version is: If everything is not on the file stack 'f951' is printed, then the '' stuff happens, from "gfc_cpp_init": cpp_change_file (cpp_in, LC_RENAME, _("")); .... cpp_change_file (cpp_in, LC_RENAME, _("")); (similar: c-family/c-opts.c: c_finish_options) This could be undone (to print 'f951') by calling cpp_change_file with to_f= ile =3D NULL =E2=80=93 but I am sure it won't have undesired side effect. And only after the file has been successfully opened, linemap_add is called. Thus, the '' shows up between gfc_cpp_init() and linemap_add. Or code wise, in gfc_init: if (!gfc_cpp_enabled ()) { linemap_add (line_table, LC_ENTER, false, gfc_source_file, 1); linemap_add (line_table, LC_RENAME, false, "", 0); } else gfc_cpp_init_0 (); ... if (gfc_cpp_enabled ()) gfc_cpp_init (); ... gfc_new_file (); with gfc_new_file: if (gfc_cpp_enabled ()) { gfc_cpp_preprocess (gfc_source_file); if (!gfc_cpp_preprocess_only ()) load_file (gfc_cpp_temporary_file (), gfc_source_file, true); } else load_file (gfc_source_file, NULL, true); and in load_file: input =3D gfc_open_file (realfilename); if (input =3D=3D NULL) gfc_fatal_error ("Cannot open file %qs", filename); ... f =3D get_file (filename, (initial && !preprocessed_p) ? LC_RENAME : LC_E= NTER); the latter then calls linemap_add (line_table, reason, false, f->filename, 1); > In either case, this points to some mess in the line-map stack. Suggestions how to improve the code above?=