public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110505] New: Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result
@ 2023-06-30 16:43 everythingfunctional at protonmail dot com
  2023-06-30 20:34 ` [Bug fortran/110505] " anlauf at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: everythingfunctional at protonmail dot com @ 2023-06-30 16:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110505
           Summary: Memory Problems with Array Constructor From Zero Size
                    Allocatable Array Function Result
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: everythingfunctional at protonmail dot com
  Target Milestone: ---

The following program breaks valgrind. Note that the loop is actually required
and can't be manually unrolled or it doesn't exhibit the same behavior.

program example
    integer :: i
    do i = 1, 2
        print *, [make_array(), make_array()]
    end do
contains
    function make_array()
        integer, allocatable :: make_array(:)

        allocate(make_array(0))
    end function
end program

$ gfortran -g example.f90
$ valgrind ./a.out       
==216962== Memcheck, a memory error detector
==216962== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==216962== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info
==216962== Command: ./a.out
==216962== 
==216962== realloc() with size 0
==216962==    at 0x4846BE0: realloc (vg_replace_malloc.c:1649)
==216962==    by 0x10960F: MAIN__ (example.f90:4)
==216962==    by 0x10976F: main (example.f90:3)
==216962==  Address 0x4e68a30 is 0 bytes after a block of size 0 alloc'd
==216962==    at 0x4846BE0: realloc (vg_replace_malloc.c:1649)
==216962==    by 0x1094BD: MAIN__ (example.f90:4)
==216962==    by 0x10976F: main (example.f90:3)
==216962== 

Error:
  unknown error code 14

Memcheck: the 'impossible' happened:
   unknown error code in mc_eq_Error

host stacktrace:
==216962==    at 0x58042CDA: show_sched_status_wrk (m_libcassert.c:406)
==216962==    by 0x58042E07: report_and_quit (m_libcassert.c:477)
==216962==    by 0x580430DF: panic (m_libcassert.c:553)
==216962==    by 0x580430DF: vgPlain_tool_panic (m_libcassert.c:568)
==216962==    by 0x58039828: vgMemCheck_eq_Error (mc_errors.c:1067)
==216962==    by 0x5803E1B7: eq_Error (m_errormgr.c:307)
==216962==    by 0x5803E1B7: vgPlain_maybe_record_error (m_errormgr.c:765)
==216962==    by 0x580390A4: vgMemCheck_record_realloc_size_zero
(mc_errors.c:896)
==216962==    by 0x5800599A: vgMemCheck_realloc (mc_malloc_wrappers.c:583)
==216962==    by 0x580A029E: do_client_request (scheduler.c:1987)
==216962==    by 0x580A029E: vgPlain_scheduler (scheduler.c:1542)
==216962==    by 0x580E58BD: thread_wrapper (syswrap-linux.c:102)
==216962==    by 0x580E58BD: run_a_thread_NORETURN (syswrap-linux.c:155)

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable (lwpid 216962)
==216962==    at 0x4846BE0: realloc (vg_replace_malloc.c:1649)
==216962==    by 0x10960F: MAIN__ (example.f90:4)
==216962==    by 0x10976F: main (example.f90:3)
client stack range: [0x1FFEFFE000 0x1FFF000FFF] client SP: 0x1FFF000130
valgrind stack range: [0x1002BAA000 0x1002CA9FFF] top usage: 10000 of 1048576


Note: see also the FAQ in the source distribution.
It contains workarounds to several common problems.
In particular, if Valgrind aborted or crashed after
identifying problems in your program, there's a good chance
that fixing those problems will prevent Valgrind aborting or
crashing, especially if it happened in m_mallocfree.c.

If that doesn't help, please report this bug to: www.valgrind.org

In the bug report, send all the above text, the valgrind
version, and what OS and version you are using.  Thanks.

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

* [Bug fortran/110505] Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result
  2023-06-30 16:43 [Bug fortran/110505] New: Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result everythingfunctional at protonmail dot com
@ 2023-06-30 20:34 ` anlauf at gcc dot gnu.org
  2023-06-30 21:40 ` everythingfunctional at protonmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-06-30 20:34 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2023-06-30
     Ever confirmed|0                           |1

--- Comment #1 from anlauf at gcc dot gnu.org ---
Works here on x86_64-pc-linux-gnu with all branches tested (7...14),
but an older version of valgrind (3.18.1).

Need more details on your system.

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

* [Bug fortran/110505] Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result
  2023-06-30 16:43 [Bug fortran/110505] New: Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result everythingfunctional at protonmail dot com
  2023-06-30 20:34 ` [Bug fortran/110505] " anlauf at gcc dot gnu.org
@ 2023-06-30 21:40 ` everythingfunctional at protonmail dot com
  2023-06-30 22:34 ` [Bug other/110505] " pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: everythingfunctional at protonmail dot com @ 2023-06-30 21:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Brad Richardson <everythingfunctional at protonmail dot com> ---
I'm on and x86 Arch Linux machine. By works do you mean valgrind doesn't report
any errors at all? I can also try a system upgrade and reboot and see if
anything changes.

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

* [Bug other/110505] Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result
  2023-06-30 16:43 [Bug fortran/110505] New: Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result everythingfunctional at protonmail dot com
  2023-06-30 20:34 ` [Bug fortran/110505] " anlauf at gcc dot gnu.org
  2023-06-30 21:40 ` everythingfunctional at protonmail dot com
@ 2023-06-30 22:34 ` pinskia at gcc dot gnu.org
  2023-06-30 22:35 ` pinskia at gcc dot gnu.org
  2023-06-30 22:43 ` everythingfunctional at protonmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-30 22:34 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|fortran                     |other

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>The following program breaks valgrind.

I suspect you should report this to valgrind instead of here. And from the
other person who tried it, it works with an older version of valgrind, I am
suspecting valgrind has a regression in it rather than libgfortran ...

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

* [Bug other/110505] Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result
  2023-06-30 16:43 [Bug fortran/110505] New: Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result everythingfunctional at protonmail dot com
                   ` (2 preceding siblings ...)
  2023-06-30 22:34 ` [Bug other/110505] " pinskia at gcc dot gnu.org
@ 2023-06-30 22:35 ` pinskia at gcc dot gnu.org
  2023-06-30 22:43 ` everythingfunctional at protonmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-30 22:35 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |MOVED
           See Also|                            |https://bugs.kde.org/show_b
                   |                            |ug.cgi?id=470520
             Status|WAITING                     |RESOLVED

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually it was reported to valgrind already:
https://bugs.kde.org/show_bug.cgi?id=470520

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

* [Bug other/110505] Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result
  2023-06-30 16:43 [Bug fortran/110505] New: Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result everythingfunctional at protonmail dot com
                   ` (3 preceding siblings ...)
  2023-06-30 22:35 ` pinskia at gcc dot gnu.org
@ 2023-06-30 22:43 ` everythingfunctional at protonmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: everythingfunctional at protonmail dot com @ 2023-06-30 22:43 UTC (permalink / raw)
  To: gcc-bugs

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

Brad Richardson <everythingfunctional at protonmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED
         Resolution|MOVED                       |INVALID

--- Comment #5 from Brad Richardson <everythingfunctional at protonmail dot com> ---
Got it. Happy to close this one then.

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

end of thread, other threads:[~2023-06-30 22:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 16:43 [Bug fortran/110505] New: Memory Problems with Array Constructor From Zero Size Allocatable Array Function Result everythingfunctional at protonmail dot com
2023-06-30 20:34 ` [Bug fortran/110505] " anlauf at gcc dot gnu.org
2023-06-30 21:40 ` everythingfunctional at protonmail dot com
2023-06-30 22:34 ` [Bug other/110505] " pinskia at gcc dot gnu.org
2023-06-30 22:35 ` pinskia at gcc dot gnu.org
2023-06-30 22:43 ` everythingfunctional at protonmail dot com

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).