public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105512] New: compilation with -fmodules-ts and std=c++20 leads to segfault
@ 2022-05-07 7:19 deco33000 at yandex dot com
2023-06-18 18:02 ` [Bug c++/105512] " gnu.w2nnu at simplelogin dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: deco33000 at yandex dot com @ 2022-05-07 7:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105512
Bug ID: 105512
Summary: compilation with -fmodules-ts and std=c++20 leads to
segfault
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: deco33000 at yandex dot com
Target Milestone: ---
Hi,
compiling with -fmodules-ts and -std=c++20 leads to a segfault. With c++17 no
errors. Without std= switch, no segfault.
But c++20 is required in my code, hence the report.
Here is the reduced code:
----- main.cpp
import hello;
int main ( void ){
X::greeter("ok");
return 0;
}
-----mod.cxx
module;
#include <iostream>
#include <string_view>
#include <string>
export module hello;
import sub_mod;
namespace X {
void greeter2 ( std::string_view const &name ){
std::string h = "exported greeter";
std::cout << "Bye " << name << "!" << h << "\n";
Y::g();
}
}
export {
namespace X {
void greeter ( std::string_view const &name ){
std::string h = "exported greeter";
std::cout << "Hello " << name << "!" << h << "\n";
greeter2("ff");
}
}
}
-----mod_sub.cxx
module;
#include <iostream>
export module sub_mod;
export {
namespace Y {
auto g (){
std::cout << "in out " << std::endl;
}
}
}
The following works with c++17 and c++20 flags (no issue):
----- mod_sub.cxx corrected (no global fragment):
export module sub_mod;
export {
namespace Y {
auto g ()-> int{
//std::cout << "in out " << std::endl;
return 54;
}
}
}
and
----- mod.cxx corrected (prints g() directly):
module;
#include <iostream>
#include <string_view>
#include <string>
export module hello;
import sub_mod;
namespace X {
void greeter2 ( std::string_view const &name ){
std::string h = "exported greeter";
std::cout << "Bye " << name << "!" << h << " " <<
Y::g() <<"\n";
}
}
export {
namespace X {
void greeter ( std::string_view const &name ){
std::string h = "exported greeter";
std::cout << "Hello " << name << "!" << h << "\n";
greeter2("ff");
}
}
}
Thanks,
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105512] compilation with -fmodules-ts and std=c++20 leads to segfault
2022-05-07 7:19 [Bug c++/105512] New: compilation with -fmodules-ts and std=c++20 leads to segfault deco33000 at yandex dot com
@ 2023-06-18 18:02 ` gnu.w2nnu at simplelogin dot com
2023-09-08 20:12 ` mail@gerrit-albrecht.de
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: gnu.w2nnu at simplelogin dot com @ 2023-06-18 18:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105512
David Truby <gnu.w2nnu at simplelogin dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gnu.w2nnu at simplelogin dot com
--- Comment #1 from David Truby <gnu.w2nnu at simplelogin dot com> ---
I also see this issue and have a reproducer here:
---- main.cpp
#include <iostream>
#include <string>
import test;
int main() {
std::cout << tester();
}
---- test.cpp
module;
#include <string>
export module test;
export std::string tester() {
return "hello world\n";
}
----
Interestingly the issue also goes away if -D_GLIBCXX_USE_CXX11_ABI=0 is passed
to both TUs so I suspect there's an issue with the module file not exporting
the correct ABI for `std::string`
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105512] compilation with -fmodules-ts and std=c++20 leads to segfault
2022-05-07 7:19 [Bug c++/105512] New: compilation with -fmodules-ts and std=c++20 leads to segfault deco33000 at yandex dot com
2023-06-18 18:02 ` [Bug c++/105512] " gnu.w2nnu at simplelogin dot com
@ 2023-09-08 20:12 ` mail@gerrit-albrecht.de
2024-03-06 21:26 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mail@gerrit-albrecht.de @ 2023-09-08 20:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105512
Gerrit Albrecht <mail@gerrit-albrecht.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mail@gerrit-albrecht.de
--- Comment #2 from Gerrit Albrecht <mail@gerrit-albrecht.de> ---
Hi. I can confirm both reports. Tried it with "g++.exe (Rev2, Built by MSYS2
project) 13.2.0" MinGW64 compiler; both -std=c++23 and -std=c++20 segfault
together with -fmodules-ts. It works without -std option and with
D_GLIBCXX_USE_CXX11_ABI=0. Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105512] compilation with -fmodules-ts and std=c++20 leads to segfault
2022-05-07 7:19 [Bug c++/105512] New: compilation with -fmodules-ts and std=c++20 leads to segfault deco33000 at yandex dot com
2023-06-18 18:02 ` [Bug c++/105512] " gnu.w2nnu at simplelogin dot com
2023-09-08 20:12 ` mail@gerrit-albrecht.de
@ 2024-03-06 21:26 ` ppalka at gcc dot gnu.org
2024-03-07 21:24 ` cvs-commit at gcc dot gnu.org
2024-03-07 21:25 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-06 21:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105512
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Ever confirmed|0 |1
Last reconfirmed| |2024-03-06
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=110730
Status|UNCONFIRMED |ASSIGNED
CC| |ppalka at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to David Truby from comment #1)
> Interestingly the issue also goes away if -D_GLIBCXX_USE_CXX11_ABI=0 is
> passed to both TUs so I suspect there's an issue with the module file not
> exporting the correct ABI for `std::string`
Good catch, so this is the same underlying issue as in PR110730.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105512] compilation with -fmodules-ts and std=c++20 leads to segfault
2022-05-07 7:19 [Bug c++/105512] New: compilation with -fmodules-ts and std=c++20 leads to segfault deco33000 at yandex dot com
` (2 preceding siblings ...)
2024-03-06 21:26 ` ppalka at gcc dot gnu.org
@ 2024-03-07 21:24 ` cvs-commit at gcc dot gnu.org
2024-03-07 21:25 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-07 21:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105512
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:0552560f6d2eaa1ae6df5c80660b489de1d5c772
commit r14-9372-g0552560f6d2eaa1ae6df5c80660b489de1d5c772
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Mar 7 16:23:22 2024 -0500
c++/modules: inline namespace abi_tag streaming [PR110730]
The unreduced testcase from PR110730 crashes at runtime ultimately
because we don't stream the abi_tag attribute on inline namespaces and
so the filesystem::current_path() call resolves to the non-C++11 ABI
version even though the C++11 ABI is active, leading to a crash when
destroying the path temporary (which contains an std::string member).
Similar story for the PR105512 testcase.
While we do stream the DECL_ATTRIBUTES of all decls that go through
the generic tree streaming routines, it seems namespaces are streamed
separately from other decls and we don't use the generic routines for
them. So this patch makes us stream the abi_tag manually for (inline)
namespaces.
PR c++/110730
PR c++/105512
gcc/cp/ChangeLog:
* module.cc (module_state::write_namespaces): Stream the
abi_tag attribute of an inline namespace.
(module_state::read_namespaces): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/modules/hello-2_a.C: New test.
* g++.dg/modules/hello-2_b.C: New test.
* g++.dg/modules/namespace-6_a.H: New test.
* g++.dg/modules/namespace-6_b.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105512] compilation with -fmodules-ts and std=c++20 leads to segfault
2022-05-07 7:19 [Bug c++/105512] New: compilation with -fmodules-ts and std=c++20 leads to segfault deco33000 at yandex dot com
` (3 preceding siblings ...)
2024-03-07 21:24 ` cvs-commit at gcc dot gnu.org
@ 2024-03-07 21:25 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-07 21:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105512
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Target Milestone|--- |14.0
Resolution|--- |FIXED
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14, thanks for the bug reports.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-03-07 21:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-07 7:19 [Bug c++/105512] New: compilation with -fmodules-ts and std=c++20 leads to segfault deco33000 at yandex dot com
2023-06-18 18:02 ` [Bug c++/105512] " gnu.w2nnu at simplelogin dot com
2023-09-08 20:12 ` mail@gerrit-albrecht.de
2024-03-06 21:26 ` ppalka at gcc dot gnu.org
2024-03-07 21:24 ` cvs-commit at gcc dot gnu.org
2024-03-07 21:25 ` ppalka 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).