From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BDC003858C33; Wed, 19 Jul 2023 06:43:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BDC003858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689749009; bh=kVvZ0IMVDnW1Rbk9/mowUwuMKHlEA3/bQc3vob0XW+s=; h=From:To:Subject:Date:From; b=bIH7boHKUIHKZVq9PLEH5FvZkcAyizhd3iXoF6qfSSwR7hL8OjeIc5zHKlMdhiFyV W7lqxmxHtthdwD7M9yZN9kpXE9zubWdxsTAZQYqqW5T8M9973SxJWCBrVJEniHwgFO 3IME84DVJuGZeaPJ5vrtXyLFqzOH1hwkG2qnLFNM= From: "nishuangcheng at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110730] New: STL internal allocation/deallocation might lead to core dump in the use of header units of the modules feature Date: Wed, 19 Jul 2023 06:43:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nishuangcheng at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110730 Bug ID: 110730 Summary: STL internal allocation/deallocation might lead to core dump in the use of header units of the modules feature Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nishuangcheng at gmail dot com Target Milestone: --- --- the exact version of GCC: 14.0.0 --- the system type: Linux, Ubuntu 22.04.2 LTS, x86_64 --- the options given when GCC was configured/built: --enable-default-pie --enable-host-pie --enable-host-shared --enable-languages=3Ddefault,go --enable-threads=3Dposix --with-multilib-list=3Dm32,m64,mx32 --- the complete command line that triggers the bug and the output: ###test case1### $ cat module-test.cpp=20 import ; int main(int argc, char **argv) { return !std::filesystem::exists(argc =3D=3D 1 ? std::filesystem::current_= path() : argv[1]); } $ g++ -std=3Dc++23 -fmodules-ts -Wall -Wextra -x c++-system-header filesyst= em -x c++ module-test.cpp -o module-test $ ./module-test # error free(): invalid pointer Aborted (core dumped) $ ./module-test existing_file # ok $ echo $? 0 $ ./module-test nonexisting_file # ok $ echo $? 1 ###end of test case1### ###test case2### $ cat module-test.cpp=20 import ; import ; int main() { std::cout << "PWD: " << std::filesystem::current_path() << std::endl; return 0; } $ g++ -std=3Dc++23 -fmodules-ts -Wall -Wextra -x c++-system-header filesyst= em iostream -x c++ module-test.cpp -o module-test $ ./module-test # changing the importing order produces the same result terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped) ###end of test case2### --- It seems that this is not a mere issue of multiple header-unit compilation mentioned in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99227, since th= ere is only one header unit in test case1. Besides, this is a runtime issue instead of a compile-time one. The problem= is probably related to the header unit. Thus, I only include its preprocessed file in my attachments.=