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

--- Comment #8 from Vittorio Zecca <zeccav at gmail dot com> ---
Compiling and running under both 8.0.1 and 8.1.0
with MALLOC_CHECK_=1 (see man mallopt)

I get the following (notice "free(): invalid pointer" from mallopt)

/usr/bin/gfortran -g -O0 gfbug144.f 
[vitti f95]$./a.out
free(): invalid pointer

Program received signal SIGABRT: Process abort signal.

Backtrace for this error:
#0  0x1461bb3fffcf in ???
        at
/usr/src/debug/glibc-2.27-37-g39071a5539/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
#1  0x1461bb3fff4b in __GI_raise
        at ../sysdeps/unix/sysv/linux/raise.c:51
#2  0x1461bb3ea590 in __GI_abort
        at /usr/src/debug/glibc-2.27-37-g39071a5539/stdlib/abort.c:79
#3  0x1461bb442b0a in __libc_message
        at ../sysdeps/posix/libc_fatal.c:181
#4  0x1461bb44903b in malloc_printerr
        at /usr/src/debug/glibc-2.27-37-g39071a5539/malloc/malloc.c:5350
#5  0x1461bb44cdfd in free_check
        at /usr/src/debug/glibc-2.27-37-g39071a5539/malloc/hooks.c:274
#6  0x400920 in MAIN__
        at /home/vitti/f95/gfbug144.f:11
#7  0x4009c4 in main
        at /home/vitti/f95/gfbug144.f:12
Aborted (core dumped)

with valgrind:

valgrind ./a.out
==30798== Memcheck, a memory error detector
==30798== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==30798== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==30798== Command: ./a.out
==30798== 
==30798== Invalid write of size 4
==30798==    at 0x4F0E903: matmul_i4_vanilla (matmul_i4.c:2035)
==30798==    by 0x400920: MAIN__ (gfbug144.f:11)
==30798==    by 0x4009C4: main (gfbug144.f:12)
==30798==  Address 0x6079ec4 is 0 bytes after a block of size 1,028 alloc'd
==30798==    at 0x4C2DBAB: malloc (vg_replace_malloc.c:299)
==30798==    by 0x4F0D24A: matmul_i4_vanilla (matmul_i4.c:1995)
==30798==    by 0x400920: MAIN__ (gfbug144.f:11)
==30798==    by 0x4009C4: main (gfbug144.f:12)
==30798== 
==30798== Invalid read of size 4
==30798==    at 0x4F10EE6: matmul_i4_vanilla (matmul_i4.c:2197)
==30798==    by 0x400920: MAIN__ (gfbug144.f:11)
==30798==    by 0x4009C4: main (gfbug144.f:12)
==30798==  Address 0x6079ec4 is 0 bytes after a block of size 1,028 alloc'd
==30798==    at 0x4C2DBAB: malloc (vg_replace_malloc.c:299)
==30798==    by 0x4F0D24A: matmul_i4_vanilla (matmul_i4.c:1995)
==30798==    by 0x400920: MAIN__ (gfbug144.f:11)
==30798==    by 0x4009C4: main (gfbug144.f:12)
==30798== 
==30798== Conditional jump or move depends on uninitialised value(s)
==30798==    at 0x506872E: write_decimal.constprop.10 (write.c:808)
==30798==    by 0x5068B13: write_integer (write.c:1351)
==30798==    by 0x5069AED: list_formatted_write_scalar (write.c:1865)
==30798==    by 0x506A834: _gfortrani_list_formatted_write (write.c:1943)
==30798==    by 0x400966: MAIN__ (gfbug144.f:11)
==30798==    by 0x4009C4: main (gfbug144.f:12)
==30798== 
           7          10
==30798== 
==30798== HEAP SUMMARY:
==30798==     in use at exit: 0 bytes in 0 blocks
==30798==   total heap usage: 22 allocs, 22 frees, 14,548 bytes allocated
==30798== 
==30798== All heap blocks were freed -- no leaks are possible
==30798== 
==30798== For counts of detected and suppressed errors, rerun with: -v
==30798== Use --track-origins=yes to see where uninitialised values come from
==30798== ERROR SUMMARY: 4 errors from 3 contexts (suppressed: 0 from 0)

Reply via email to