public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110894] New: [modules] Program terminates with signal SIGSEGV
@ 2023-08-03 19:29 johelegp at gmail dot com
  2023-08-03 19:41 ` [Bug c++/110894] " johelegp at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: johelegp at gmail dot com @ 2023-08-03 19:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110894
           Summary: [modules] Program terminates with signal SIGSEGV
           Product: gcc
           Version: 14.0
               URL: https://cpp2.godbolt.org/z/7YrvenrzT
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
                CC: johelegp at gmail dot com
  Target Milestone: ---

Please, see <https://cpp2.godbolt.org/z/7YrvenrzT>.
It has the source files,
and in the output,
the compile commands along with the errors.

```
$ cat module.cpp 
module;
#include <string>
export module hello;
export auto hello() -> std::string { return "Hello";  }
$ cat main.cpp 
#include <iostream>
import hello;
auto main() -> int { std::cout << hello() << ", modules!\n";  }
```

```
[1/6] /opt/compiler-explorer/clang-16.0.0/bin/clang-scan-deps -format=p1689 --
/opt/compiler-explorer/gcc-snapshot/bin/g++   -O0 -std=c++2b -pedantic-errors
-Wall -Wextra -Wconversion -Werror=unused-result -isystem
/opt/compiler-explorer/gcc-snapshot/bin/../lib/gcc/x86_64-linux-gnu/14.0.0/include
-x c++ /app/module.cpp -c -o CMakeFiles/main.dir/module.cpp.o -MT
CMakeFiles/main.dir/module.cpp.o.ddi -MD -MF
CMakeFiles/main.dir/module.cpp.o.ddi.d > CMakeFiles/main.dir/module.cpp.o.ddi
[2/6] /opt/compiler-explorer/clang-16.0.0/bin/clang-scan-deps -format=p1689 --
/opt/compiler-explorer/gcc-snapshot/bin/g++   -O0 -std=c++2b -pedantic-errors
-Wall -Wextra -Wconversion -Werror=unused-result -isystem
/opt/compiler-explorer/gcc-snapshot/bin/../lib/gcc/x86_64-linux-gnu/14.0.0/include
-x c++ /app/main.cpp -c -o CMakeFiles/main.dir/main.cpp.o -MT
CMakeFiles/main.dir/main.cpp.o.ddi -MD -MF CMakeFiles/main.dir/main.cpp.o.ddi.d
> CMakeFiles/main.dir/main.cpp.o.ddi
[3/6] /opt/compiler-explorer/cmake-v3.26.1/bin/cmake -E cmake_ninja_dyndep
--tdi=CMakeFiles/main.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc
--dd=CMakeFiles/main.dir/CXX.dd @CMakeFiles/main.dir/CXX.dd.rsp
[4/6] /opt/compiler-explorer/gcc-snapshot/bin/g++   -O0 -std=c++2b
-pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -MD -MT
CMakeFiles/main.dir/module.cpp.o -MF CMakeFiles/main.dir/module.cpp.o.d
-fmodules-ts -Mno-modules
-fmodule-mapper=CMakeFiles/main.dir/module.cpp.o.modmap -x c++ -o
CMakeFiles/main.dir/module.cpp.o -c /app/module.cpp
[5/6] /opt/compiler-explorer/gcc-snapshot/bin/g++   -O0 -std=c++2b
-pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -MD -MT
CMakeFiles/main.dir/main.cpp.o -MF CMakeFiles/main.dir/main.cpp.o.d
-fmodules-ts -Mno-modules -fmodule-mapper=CMakeFiles/main.dir/main.cpp.o.modmap
-x c++ -o CMakeFiles/main.dir/main.cpp.o -c /app/main.cpp
[6/6] : && /opt/compiler-explorer/gcc-snapshot/bin/g++ -O0 -std=c++2b
-pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -L/app
-Wl,-rpath,/app -Wl,-rpath,/opt/compiler-explorer/gcc-snapshot/lib64
-Wl,-rpath,/opt/compiler-explorer/gcc-snapshot/lib32
CMakeFiles/main.dir/main.cpp.o CMakeFiles/main.dir/module.cpp.o -o main   && :
Program returned: 139
Program terminated with signal: SIGSEGV
```

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

* [Bug c++/110894] [modules] Program terminates with signal SIGSEGV
  2023-08-03 19:29 [Bug c++/110894] New: [modules] Program terminates with signal SIGSEGV johelegp at gmail dot com
@ 2023-08-03 19:41 ` johelegp at gmail dot com
  2023-08-03 19:50 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: johelegp at gmail dot com @ 2023-08-03 19:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
If instead I use `std::string_view` in `-O3` (`-O0` works),
it also diagnoses (<https://cpp2.godbolt.org/z/h7zooM35G>):

```
In file included from /app/module.cpp:2,
of module hello, imported at /app/main.cpp:2:
In member function 'constexpr const std::basic_string_view<_CharT,
_Traits>::value_type* std::basic_string_view<_CharT, _Traits>::data() const
[with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'std::basic_ostream<_CharT, _Traits>&
std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT,
_Traits>) [with _CharT = char; _Traits = char_traits<char>]' at
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view:762:30,
    inlined from 'int main()' at /app/main.cpp:3:46:
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view:292:22:
warning: 'this' is used uninitialized [-Wuninitialized]
  292 |       { return this->_M_str; }
      |                      ^~~~~~
In file included from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/bits/basic_string.h:47,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string:54,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/bits/locale_classes.h:40,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/bits/ios_base.h:41,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/ios:44,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/ostream:40,
                 from
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/iostream:41,
                 from /app/main.cpp:1:
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view: In
function 'int main()':
/opt/compiler-explorer/gcc-trunk-20230801/include/c++/14.0.0/string_view:760:5:
note: 'this' was declared here
  760 |     operator<<(basic_ostream<_CharT, _Traits>& __os,
      |     ^~~~~~~~
```

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

* [Bug c++/110894] [modules] Program terminates with signal SIGSEGV
  2023-08-03 19:29 [Bug c++/110894] New: [modules] Program terminates with signal SIGSEGV johelegp at gmail dot com
  2023-08-03 19:41 ` [Bug c++/110894] " johelegp at gmail dot com
@ 2023-08-03 19:50 ` pinskia at gcc dot gnu.org
  2023-08-03 23:06 ` johelegp at gmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-03 19:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|https://cpp2.godbolt.org/z/ |
                   |7YrvenrzT                   |
         Depends on|103524                      |109953
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=98761
             Blocks|                            |103524

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://cpp2.godbolt.org/z/7YrvenrzT

Most likely a dup of bug 109953.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524
[Bug 103524] [meta-bug] modules issue
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109953
[Bug 109953] [c++modules] segmentation fault with import "functional" during
program execution

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

* [Bug c++/110894] [modules] Program terminates with signal SIGSEGV
  2023-08-03 19:29 [Bug c++/110894] New: [modules] Program terminates with signal SIGSEGV johelegp at gmail dot com
  2023-08-03 19:41 ` [Bug c++/110894] " johelegp at gmail dot com
  2023-08-03 19:50 ` pinskia at gcc dot gnu.org
@ 2023-08-03 23:06 ` johelegp at gmail dot com
  2024-02-16  0:20 ` nshead at gcc dot gnu.org
  2024-02-16  0:27 ` nshead at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: johelegp at gmail dot com @ 2023-08-03 23:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Reduced: <https://cpp2.godbolt.org/z/f3K4WaKnE>.

If you comment out the use of `.data()` at the end of `my_string_view.hpp` it
works.
It originally comes from `<string_view>`'s specialization of `hash`,
`      { return std::_Hash_impl::hash(__str.data(), __str.length()); }`.

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

* [Bug c++/110894] [modules] Program terminates with signal SIGSEGV
  2023-08-03 19:29 [Bug c++/110894] New: [modules] Program terminates with signal SIGSEGV johelegp at gmail dot com
                   ` (2 preceding siblings ...)
  2023-08-03 23:06 ` johelegp at gmail dot com
@ 2024-02-16  0:20 ` nshead at gcc dot gnu.org
  2024-02-16  0:27 ` nshead at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-02-16  0:20 UTC (permalink / raw)
  To: gcc-bugs

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

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |nshead at gcc dot gnu.org
   Target Milestone|---                         |14.0
         Resolution|---                         |FIXED

--- Comment #4 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Looks to be fixed on GCC 14 trunk.

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

* [Bug c++/110894] [modules] Program terminates with signal SIGSEGV
  2023-08-03 19:29 [Bug c++/110894] New: [modules] Program terminates with signal SIGSEGV johelegp at gmail dot com
                   ` (3 preceding siblings ...)
  2024-02-16  0:20 ` nshead at gcc dot gnu.org
@ 2024-02-16  0:27 ` nshead at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-02-16  0:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110894
Bug 110894 depends on bug 109953, which changed state.

Bug 109953 Summary: [c++modules] segmentation fault with import "functional" during program execution
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109953

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

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

end of thread, other threads:[~2024-02-16  0:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-03 19:29 [Bug c++/110894] New: [modules] Program terminates with signal SIGSEGV johelegp at gmail dot com
2023-08-03 19:41 ` [Bug c++/110894] " johelegp at gmail dot com
2023-08-03 19:50 ` pinskia at gcc dot gnu.org
2023-08-03 23:06 ` johelegp at gmail dot com
2024-02-16  0:20 ` nshead at gcc dot gnu.org
2024-02-16  0:27 ` nshead 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).