From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5DDC63854812; Tue, 18 May 2021 14:05:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DDC63854812 From: "matthew.thompson at nasa dot gov" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/100651] New: Weird memory corruption with multiple triggers Date: Tue, 18 May 2021 14:05:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: matthew.thompson at nasa dot gov 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 attachments.created 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 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: Tue, 18 May 2021 14:05:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100651 Bug ID: 100651 Summary: Weird memory corruption with multiple triggers Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: matthew.thompson at nasa dot gov Target Milestone: --- Created attachment 50838 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D50838&action=3Dedit Reproducing program This is a bug that is tripped by GCC 9.3.0, 10.1.0, and 11.1.0 (at least, b= ut I only have access to those) on Linux and macOS. For the rest of this bug rep= ort, I'll be using macOS (as it's my main workstation). First: =E2=9D=AF gfortran -v Using built-in specs. COLLECT_GCC=3Dgfortran COLLECT_LTO_WRAPPER=3D/Users/mathomp4/installed/Core/gcc-gfortran/11.1.0/li= bexec/gcc/x86_64-apple-darwin19.6.0/11.1.0/lto-wrapper Target: x86_64-apple-darwin19.6.0 Configured with: ../gcc-11.1.0/configure --prefix=3D/Users/mathomp4/installed/Core/gcc-gfortran/11.1.0 --enable-languages=3Dc,c++,fortran --with-sysroot=3D/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.1.0 (GCC) If you compile and run (NOTE: the -g -O0 is not necessary, I only use it to make the traceback a bit better): =E2=9D=AF gfortran -g -O0 opt_string.F90 =E2=9D=AF ./a.out opt_string.F90 122 T opt_string.F90 123 542594713 a.out(15473,0x1129d4e00) malloc: can't allocate region :*** mach_vm_map(size=3D140733735985152, flags: 100) failed (error code=3D3) a.out(15473,0x1129d4e00) malloc: *** set a breakpoint in malloc_error_break= to debug Operating system error: Cannot allocate memory Memory allocation failure in xrealloc Error termination. Backtrace: #0 0x103249de2 in ??? #1 0x10324aab5 in ??? #2 0x10324acb3 in ??? #3 0x10324939a in ??? #4 0x10347a455 in ??? #5 0x10346bb99 in ??? #6 0x1034740a7 in ??? #7 0x1034792be in ??? #8 0x10347a237 in ??? #9 0x103231c2d in __test_intnode_MOD_test_casting_fail at /Users/mathomp4/F90Files/TomOptStringGCCBug/opt_string.F90:124 #10 0x103231c5c in MAIN__ at /Users/mathomp4/F90Files/TomOptStringGCCBug/opt_string.F90:135 #11 0x103231c98 in main at /Users/mathomp4/F90Files/TomOptStringGCCBug/opt_string.F90:132 The (runtime) error disappears if *any* of the following 3 lines are commen= ted out/deleted: * Line 31 (generic assignment) * Line 85 (unused component of a derived type) * Line 121 (unused local variable) On Linux the output is: $ ./a.out opt_string.F90 122 T opt_string.F90 123 -1431350024 Operating system error: Cannot allocate memory Memory allocation failure in xrealloc Error termination. Backtrace: #0 0x2aaaaaf20a07 in write_character at ../../../gcc-11.1.0/libgfortran/io/write.c:1416 #1 0x2aaaaaf25ba6 in list_formatted_write_scalar at ../../../gcc-11.1.0/libgfortran/io/write.c:1900 #2 0x400cef in __test_intnode_MOD_test_casting_fail at /home/mathomp4/F90Files/TomOptStringGCCBug/opt_string.F90:124 #3 0x400d1e in MAIN__ at /home/mathomp4/F90Files/TomOptStringGCCBug/opt_string.F90:135 #4 0x400d55 in main at /home/mathomp4/F90Files/TomOptStringGCCBug/opt_string.F90:132=