https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81939
Bug ID: 81939 Summary: valgrind error message in build_float_string and heap-buffer-overflow on address sanitized libgfortran.so Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: unassigned at gcc dot gnu.org Reporter: zeccav at gmail dot com Target Milestone: --- Host: x86_64-pc-linux-gnu Build: trunk 251201 ! must be compiled and run under valgrind ! test case fmt_f0_2.f90 valgrind error message ! and heap-buffer-overflow on address sanitized libgfortran.so ! also gets MALLOC_CHECK_ error messages *** Error in `./a.out': free(): invalid pointer: 0x0000000000c63560 *** *** Error in `./a.out': free(): invalid pointer: 0x0000000000c636a0 *** *** Error in `./a.out': free(): invalid pointer: 0x0000000000c649f0 *** program testbigf0 use ISO_FORTRAN_ENV implicit none integer i integer,parameter::j(size(real_kinds)+4)=[REAL_KINDS,[4, 4, 4, 4]] character(10000) :: str do i=1,size(real_kinds) select case (i) case (1) write(str, "(f0.0)") -huge(real(1.0,kind=j(1))) case (2) write(str, "(f0.0)") -huge(real(1.0,kind=j(2))) case (3) write(str, "(f0.0)") -huge(real(1.0,kind=j(3))) case (4) write(str, "(f0.10)") -huge(real(1.0,kind=j(4))) end select enddo end program testbigf0 !==5889== Memcheck, a memory error detector !==5889== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. !==5889== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info !==5889== Command: ./a.out !==5889== !==5889== Invalid write of size 1 !==5889== at 0x50359DC: build_float_string (write_float.def:665) !==5889== by 0x5036483: get_float_string (write_float.def:1079) !==5889== by 0x50376B0: write_float_0 (write.c:1596) !==5889== by 0x502EDEC: formatted_transfer_scalar_write (transfer.c:2041) !==5889== by 0x502F41C: formatted_transfer (transfer.c:2279) !==5889== by 0x40088A: MAIN__ (p.f90:15) !==5889== by 0x400A15: main (p.f90:22) !==5889== Address 0x5dbcd37 is 0 bytes after a block of size 311 alloc'd !==5889== at 0x4C2EB6B: malloc (vg_replace_malloc.c:299) !==5889== by 0x4E55404: _gfortrani_xmalloc (memory.c:42) !==5889== by 0x5037667: write_float_0 (write.c:1592) !==5889== by 0x502EDEC: formatted_transfer_scalar_write (transfer.c:2041) !==5889== by 0x502F41C: formatted_transfer (transfer.c:2279) !==5889== by 0x40088A: MAIN__ (p.f90:15) !==5889== by 0x400A15: main (p.f90:22) !==5889== !==5889== !==5889== HEAP SUMMARY: !==5889== in use at exit: 4,935 bytes in 1 blocks !==5889== total heap usage: 43 allocs, 42 frees, 75,121 bytes allocated !==5889== !==5889== LEAK SUMMARY: !==5889== definitely lost: 4,935 bytes in 1 blocks !==5889== indirectly lost: 0 bytes in 0 blocks !==5889== possibly lost: 0 bytes in 0 blocks !==5889== still reachable: 0 bytes in 0 blocks !==5889== suppressed: 0 bytes in 0 blocks !==5889== Rerun with --leak-check=full to see details of leaked memory !==5889== !==5889== For counts of detected and suppressed errors, rerun with: -v !==5889== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 0 from 0)