public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100651] New: Weird memory corruption with multiple triggers
@ 2021-05-18 14:05 matthew.thompson at nasa dot gov
  2021-05-20 10:21 ` [Bug fortran/100651] " gscfq@t-online.de
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: matthew.thompson at nasa dot gov @ 2021-05-18 14:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100651

            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=50838&action=edit
Reproducing program

This is a bug that is tripped by GCC 9.3.0, 10.1.0, and 11.1.0 (at least, but I
only have access to those) on Linux and macOS. For the rest of this bug report,
I'll be using macOS (as it's my main workstation). First:

❯ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/Users/mathomp4/installed/Core/gcc-gfortran/11.1.0/libexec/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=/Users/mathomp4/installed/Core/gcc-gfortran/11.1.0
--enable-languages=c,c++,fortran
--with-sysroot=/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):

❯ gfortran -g -O0 opt_string.F90
❯ ./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=140733735985152, flags: 100) failed (error code=3)
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 commented
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

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2023-12-10 20:17 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 14:05 [Bug fortran/100651] New: Weird memory corruption with multiple triggers matthew.thompson at nasa dot gov
2021-05-20 10:21 ` [Bug fortran/100651] " gscfq@t-online.de
2021-05-20 10:23 ` gscfq@t-online.de
2021-07-29 15:35 ` iains at gcc dot gnu.org
2021-07-29 16:07 ` iains at gcc dot gnu.org
2021-07-29 17:35 ` matthew.thompson at nasa dot gov
2021-07-29 18:34 ` [Bug fortran/100651] [9/10/11/12 Regression] " iains at gcc dot gnu.org
2021-09-19 23:14 ` pinskia at gcc dot gnu.org
2022-01-17 14:41 ` rguenth at gcc dot gnu.org
2022-05-27  9:45 ` [Bug fortran/100651] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:45 ` jakub at gcc dot gnu.org
2023-07-07 10:39 ` [Bug fortran/100651] [11/12/13/14 " rguenth at gcc dot gnu.org
2023-11-25 10:11 ` fxcoudert at gcc dot gnu.org
2023-11-25 18:59 ` [Bug fortran/100651] [11/12/13/14 Regression] Bad handling of optional, allocatable character argument anlauf at gcc dot gnu.org
2023-11-26 20:37 ` anlauf at gcc dot gnu.org
2023-11-26 20:47 ` anlauf at gcc dot gnu.org
2023-11-26 21:15 ` anlauf at gcc dot gnu.org
2023-11-27 19:33 ` anlauf at gcc dot gnu.org
2023-12-02 14:15 ` cvs-commit at gcc dot gnu.org
2023-12-10 20:14 ` cvs-commit at gcc dot gnu.org
2023-12-10 20:17 ` anlauf at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).