public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gcasper42 at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/94810] New: std::cout segmentation fault in __attribute__((constructor)) function Date: Mon, 27 Apr 2020 21:44:52 +0000 [thread overview] Message-ID: <bug-94810-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94810 Bug ID: 94810 Summary: std::cout segmentation fault in __attribute__((constructor)) function Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: gcasper42 at gmail dot com Target Milestone: --- Created attachment 48389 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48389&action=edit Code to reproduce bug Exact Version of GCC: g++ (Arch Linux 9.3.0-1) 9.3.0 System Type: Arch Linux (under Windows Subsystem for Linux 1) The attached code compiles and runs, but runs into a seg fault. The seg fault occurs when trying to print using std::cout in my function marked with the __attribute__((constructor)), but when I instead use printf to print there is no seg fault. See end for successful build environment. GDB Stacktrace/Useful Output: Program received signal SIGSEGV, Segmentation fault. 0x00007fffff6e661a in std::ostream::sentry::sentry (this=0x7ffffffee460, __os=...) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ostream.tcc:46 46 /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ostream.tcc: No such file or directory. (gdb) bt #0 0x00007fffff6e661a in std::ostream::sentry::sentry (this=0x7ffffffee460, __os=...) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ostream.tcc:46 #1 0x00007fffff6e6d4c in std::__ostream_insert<char, std::char_traits<char> > (__out=..., __s=__s@entry=0x8002005 "Starting", __n=8) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ostream_insert.h:76 #2 0x00007fffff6e722e in std::operator<< <std::char_traits<char> > ( __out=..., __s=0x8002005 "Starting") at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:335 #3 0x0000000008001180 in constructor () at test.cpp:4 #4 0x00000000080012ad in __libc_csu_init () #5 0x00007fffff2b6fb0 in __libc_start_main () from /usr/lib/libc.so.6 #6 0x000000000800109e in _start () Something weird to mention (other build environment): While using the below build environment, the attached code runs as expected. Exact Version of GCC: g++.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0 System Type: MinGW-W64 Windows 10
next reply other threads:[~2020-04-27 21:44 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-27 21:44 gcasper42 at gmail dot com [this message] 2020-04-27 22:32 ` [Bug libstdc++/94810] " redi at gcc dot gnu.org 2020-04-27 23:41 ` gcasper42 at gmail dot com 2020-04-28 8:51 ` redi at gcc dot gnu.org 2020-04-28 13:16 ` gcasper42 at gmail dot com 2020-04-28 16:07 ` redi at gcc dot gnu.org 2020-04-28 16:09 ` redi at gcc dot gnu.org 2020-04-28 17:39 ` gcasper42 at gmail dot com 2020-04-28 20:52 ` redi at gcc dot gnu.org 2023-02-03 19:29 ` murugesandins at gmail dot com 2023-02-03 19:47 ` pinskia at gcc dot gnu.org 2023-02-03 22:04 ` murugesandins at gmail dot com 2023-02-04 3:22 ` murugesandins at gmail dot com 2023-02-06 4:41 ` murugesandins at gmail dot com
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-94810-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: linkBe 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).