public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/111341] New: Elemental operator on zero-sized array seg-faults
@ 2023-09-08 19:13 everythingfunctional at protonmail dot com
  2023-09-10  5:17 ` [Bug fortran/111341] " kargl at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: everythingfunctional at protonmail dot com @ 2023-09-08 19:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111341
           Summary: Elemental operator on zero-sized array seg-faults
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: everythingfunctional at protonmail dot com
  Target Milestone: ---

There were some scenarios in the real code for this that it doesn't segfault,
but the following reproducer was able to do it reliably for me.

fpm.toml

name = "empty_elemental"
version = "0.1.0"
license = "license"
author = "Brad Richardson"
maintainer = "everythingfunctional@protonmail.com"
copyright = "Copyright 2023, Brad Richardson"

[dependencies]
strff = { git = "https://gitlab.com/everythingfunctional/strff.git", tag =
"v4.0.0" }
iso_varying_string = { git =
"https://gitlab.com/everythingfunctional/iso_varying_string.git", tag =
"v3.0.3" }

app/main.f90

program main
  use iso_varying_string, only: varying_string, operator(//), put_line
  use strff, only: join

  implicit none

  call put_line(join("'" // empty() // "'", ","))
contains
  pure function empty()
    type(varying_string), allocatable :: empty(:)
    allocate(empty(0))
  end function
end program main

For context, varying_string just has an allocatable deferred length character
component, operator(//) is elemental, join concatenates an array of strings
with the given separator between each, and put_line is basically just print for
varying_string. So the above program should just print a single, zero length
character.

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

* [Bug fortran/111341] Elemental operator on zero-sized array seg-faults
  2023-09-08 19:13 [Bug fortran/111341] New: Elemental operator on zero-sized array seg-faults everythingfunctional at protonmail dot com
@ 2023-09-10  5:17 ` kargl at gcc dot gnu.org
  2023-09-11 13:49 ` everythingfunctional at protonmail dot com
  2023-09-11 18:29 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-09-10  5:17 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org
           Priority|P3                          |P4

--- Comment #1 from kargl at gcc dot gnu.org ---
gfcx -c a.f90
a.f90:3:7:

    3 |   use iso_varying_string, only: varying_string, operator(//), put_line
      |       1
Fatal Error: Cannot open module file 'iso_varying_string.mod' for reading at
(1: No such file or directory


Unforturnately, it seems the issue cannot be reproduced.

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

* [Bug fortran/111341] Elemental operator on zero-sized array seg-faults
  2023-09-08 19:13 [Bug fortran/111341] New: Elemental operator on zero-sized array seg-faults everythingfunctional at protonmail dot com
  2023-09-10  5:17 ` [Bug fortran/111341] " kargl at gcc dot gnu.org
@ 2023-09-11 13:49 ` everythingfunctional at protonmail dot com
  2023-09-11 18:29 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: everythingfunctional at protonmail dot com @ 2023-09-11 13:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Brad Richardson <everythingfunctional at protonmail dot com> ---
You'll need to use fpm. I.e.

$ tree
.
├── app
│   └── main.f90
└── fpm.toml
$ fpm run
 + mkdir -p build/dependencies
Initialized empty Git repository in
/home/brad/examples/empty_elemental/build/dependencies/strff/.git/
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 27 (delta 4), reused 20 (delta 1), pack-reused 0
Unpacking objects: 100% (27/27), 16.98 KiB | 2.42 MiB/s, done.
From https://gitlab.com/everythingfunctional/strff
 * tag               v4.0.0     -> FETCH_HEAD
Initialized empty Git repository in
/home/brad/examples/empty_elemental/build/dependencies/iso_varying_string/.git/
remote: Enumerating objects: 77, done.
remote: Counting objects: 100% (77/77), done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 77 (delta 34), reused 12 (delta 0), pack-reused 0
Unpacking objects: 100% (77/77), 35.35 KiB | 1.77 MiB/s, done.
From https://gitlab.com/everythingfunctional/iso_varying_string
 * tag               v3.0.3     -> FETCH_HEAD
Initialized empty Git repository in
/home/brad/examples/empty_elemental/build/dependencies/exceptional_numbers/.git/
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 18 (delta 3), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (18/18), 6.84 KiB | 1.37 MiB/s, done.
From https://gitlab.com/everythingfunctional/exceptional_numbers
 * tag               v0.1.1     -> FETCH_HEAD
iso_varying_string.f90                 done.
exceptional_numbers.f90                done.
strff.f90                              done.
libempty_elemental.a                   done.
main.f90                               done.
empty_elemental                        done.
[100%] Project compiled successfully.
free(): invalid pointer

Program received signal SIGABRT: Process abort signal.

Backtrace for this error:
#0  0x7f66af03e70f in ???
#1  0x7f66af08e83c in ???
#2  0x7f66af03e667 in ???
#3  0x7f66af0264b7 in ???
#4  0x7f66af02738f in ???
#5  0x7f66af0987b6 in ???
#6  0x7f66af09aa73 in ???
#7  0x7f66af09d352 in ???
#8  0x55a317611bff in MAIN__
        at app/main.f90:7
#9  0x55a317611cae in main
        at app/main.f90:2
<ERROR> Execution for object " empty_elemental " returned exit code  134
<ERROR> *cmd_run*:stopping due to failed executions
STOP 134

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

* [Bug fortran/111341] Elemental operator on zero-sized array seg-faults
  2023-09-08 19:13 [Bug fortran/111341] New: Elemental operator on zero-sized array seg-faults everythingfunctional at protonmail dot com
  2023-09-10  5:17 ` [Bug fortran/111341] " kargl at gcc dot gnu.org
  2023-09-11 13:49 ` everythingfunctional at protonmail dot com
@ 2023-09-11 18:29 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-09-11 18:29 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2023-09-11

--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to Brad Richardson from comment #2)
> You'll need to use fpm. I.e.

Please provide a self-contained testcase.
Ideally a minimal reproducer.

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

end of thread, other threads:[~2023-09-11 18:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-08 19:13 [Bug fortran/111341] New: Elemental operator on zero-sized array seg-faults everythingfunctional at protonmail dot com
2023-09-10  5:17 ` [Bug fortran/111341] " kargl at gcc dot gnu.org
2023-09-11 13:49 ` everythingfunctional at protonmail dot com
2023-09-11 18:29 ` 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).