public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Solaris 11 Sparc crash in std::call_once
@ 2018-08-21  9:08 Jeffrey Walton
  2018-08-21  9:11 ` Jonathan Wakely
  2018-08-21 11:02 ` Jeffrey Walton
  0 siblings, 2 replies; 5+ messages in thread
From: Jeffrey Walton @ 2018-08-21  9:08 UTC (permalink / raw)
  To: gcc-help

Hi everyone,

I have some boilerplate call_once code that sets a few function pointers:

    std::once_flag s_flag;
    InitializeInteger::InitializeInteger()
    {
        std::call_once(s_flag, []() {
            SetFunctionPointers();
        });
    }

I can duplicate the crash on Linux if I don't use -pthread. The back
traces on Solaris and Linux look exactly the same when inducing the
crash on Linux.

The code is crashing on Solaris 11 Sparc. According to
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_concurrency.html,
I need -pthread and it was provided during compile and link. The
concurrency pages also states (under Threads):

    Requisite command-line flags are used for atomic operations
    and threading. Examples of this include -pthread and
    -march=native, although specifics vary depending on the host
    environment. See Command Options and Machine Dependent Options.

We can't use -march=native because it breaks distros model of distribution.

I checked both Command Options and Machine Dependent Options and
nothing jumped out at me, but I know very little about Sparc
architecture.

My question is, are other flags required on Sparc?

Thanks in advance.

==========

(gdb) bt full
#0  0x00000001005be6a8 in
std::call_once<InitializeInteger::InitializeInteger()::<lambda()> >
(__once=...,
    __f=<unknown type in /home/test/cryptest.exe, CU 0x93609c, DIE
0x97266d>) at /usr/gcc/7/include/c++/7.3.0/mutex:676
        __callable = {__(float) = @0xffffffff7fffdf27}
#1  CryptoPP::InitializeInteger::InitializeInteger (
    this=this@entry=0xffffffff7fffe170) at integer.cpp:112
No locals.
#2  0x00000001005c5d8c in Integer::Integer (this=0xffffffff7fffe170,
    encodedInteger=0x1009e5700
"\212\252\346){l\260FB\253[\axQ(N\267\022\217\032\212\252\346){l\260FB\253[\axQ(N\267\022\217\032\212\252\346){l\260FB\253[\axQ(N\267\022\217\032\212\252",
<incomplete sequence \346\051>, byteCount=64,
    s=<optimized out>, o=<optimized out>) at integer.cpp:3019
No locals.
...

==========

Solaris 11 Sparc GCC info; crashes with -pthread:

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/gcc/7/lib/gcc/sparcv9-solaris2.11/7.3.0/lto-wrapper
Target: sparcv9-solaris2.11
Configured with:
/builds/ul11u3sru-gate/components/gcc7/gcc-7.3.0/configure
--prefix=/usr/gcc/7 --mandir=/usr/gcc/7/share/man
--bindir=/usr/gcc/7/bin --libdir=/usr/gcc/7/lib
--sbindir=/usr/gcc/7/sbin --infodir=/usr/gcc/7/share/info
--libexecdir=/usr/gcc/7/lib --enable-languages=c,c++,fortran,objc
--enable-shared --enable-initfini-array --disable-rpath
--with-system-zlib --with-build-config=no
--with-gmp-include=/usr/include/gmp
--with-mpfr-include=/usr/include/mpfr --without-gnu-ld
--with-ld=/usr/bin/ld --with-gnu-as --with-as=/usr/gnu/bin/as
'BOOT_CFLAGS=-g -O2' sparcv9-solaris2.11
Thread model: posix
gcc version 7.3.0 (GCC)

==========

Here is typical compile and link. We use the same flags for each, and
drive link through the compiler.

$ gmake
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -c cryptlib.cpp
...
g++ -o cryptest.exe -DNDEBUG -g2 -O3 -fPIC -pthread -pipe test.o
<other objects> ./libcryptopp.a  -lnsl -lsocket

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

end of thread, other threads:[~2018-08-21 11:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-21  9:08 Solaris 11 Sparc crash in std::call_once Jeffrey Walton
2018-08-21  9:11 ` Jonathan Wakely
2018-08-21  9:14   ` Jeffrey Walton
2018-08-21  9:17     ` Jeffrey Walton
2018-08-21 11:02 ` Jeffrey Walton

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