public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "stephen at soliday dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/109454] New: Possible memory leak after using random_number
Date: Sun, 09 Apr 2023 00:39:22 +0000	[thread overview]
Message-ID: <bug-109454-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109454
           Summary: Possible memory leak after using random_number
           Product: gcc
           Version: 11.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stephen at soliday dot com
  Target Milestone: ---

Simple call to RANDOM_NUMBER leaves 168 bytes still reachable after the process
exits, as indicated by valgrind.

GNU Fortran:   11.3.0
valgrind:      3.18.1
Ubuntu:        22.04.2 LTS
Linux Kernel:  5.15.0-69-generic


v----- cut here --------v (rtest.f90)
program main
  use iso_fortran_env
  implicit none

  real(REAL64) :: x

  call random_number(x)

  print *, x

end program main
^----- cut here --------^

gfortran -o rtest rtest.f90

valgrind --leak-check=full --show-leak-kinds=all regulus/bin/ftest_fuzzy
./rtest

v----- cut here ---------v
==44961== Memcheck, a memory error detector
==44961== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==44961== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==44961== Command: regulus/bin/ftest_fuzzy ./rtest
==44961== 
  0.26639924712129115     
==44961== 
==44961== HEAP SUMMARY:
==44961==     in use at exit: 168 bytes in 2 blocks
==44961==   total heap usage: 133 allocs, 131 frees, 112,809 bytes allocated
==44961== 
==44961== 40 bytes in 1 blocks are still reachable in loss record 1 of 2
==44961==    at 0x484DA83: calloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==44961==    by 0x6CF8F86: ??? (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0)
==44961==    by 0x6F63F46: _gfortran_random_r8 (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0)
==44961==    by 0x1136DC: __ftest_fuzzy_test_MOD_test03 (ftest_fuzzy.f90:221)
==44961==    by 0x116FD1: MAIN__ (ftest_fuzzy.f90:238)
==44961==    by 0x11702D: main (ftest_fuzzy.f90:234)
==44961== 
==44961== 128 bytes in 1 blocks are still reachable in loss record 2 of 2
==44961==    at 0x484DCD3: realloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==44961==    by 0x70A58AC: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==44961==    by 0x70B8114: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==44961==    by 0x70A3FE1: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==44961==    by 0x400647D: call_init.part.0 (dl-init.c:70)
==44961==    by 0x4006567: call_init (dl-init.c:33)
==44961==    by 0x4006567: _dl_init (dl-init.c:117)
==44961==    by 0x40202E9: ??? (in
/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
==44961==    by 0x1: ???
==44961==    by 0x1FFF00015A: ???
==44961==    by 0x1FFF000172: ???
==44961== 
==44961== LEAK SUMMARY:
==44961==    definitely lost: 0 bytes in 0 blocks
==44961==    indirectly lost: 0 bytes in 0 blocks
==44961==      possibly lost: 0 bytes in 0 blocks
==44961==    still reachable: 168 bytes in 2 blocks
==44961==         suppressed: 0 bytes in 0 blocks
==44961== 
==44961== For lists of detected and suppressed errors, rerun with: -s
==44961== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
^----- cut here ---------^

             reply	other threads:[~2023-04-09  0:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-09  0:39 stephen at soliday dot com [this message]
2023-04-09  0:49 ` [Bug libfortran/109454] " pinskia at gcc dot gnu.org
2023-04-09  0:57 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109454-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).