From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17892 invoked by alias); 18 Aug 2014 19:04:54 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 17877 invoked by uid 89); 18 Aug 2014 19:04:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f182.google.com Received: from mail-lb0-f182.google.com (HELO mail-lb0-f182.google.com) (209.85.217.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 18 Aug 2014 19:04:49 +0000 Received: by mail-lb0-f182.google.com with SMTP id z11so4604677lbi.13 for ; Mon, 18 Aug 2014 12:04:46 -0700 (PDT) X-Received: by 10.152.179.229 with SMTP id dj5mr4592647lac.97.1408388685991; Mon, 18 Aug 2014 12:04:45 -0700 (PDT) Received: from [10.0.0.140] (148.217.broadband9.iol.cz. [90.176.217.148]) by mx.google.com with ESMTPSA id ls8sm635640lac.42.2014.08.18.12.04.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Aug 2014 12:04:44 -0700 (PDT) Message-ID: <53F24E4B.5030502@gmail.com> Date: Mon, 18 Aug 2014 19:04:00 -0000 From: =?UTF-8?B?VsOhY2xhdiBaZW1hbg==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: Re: init_priority attribute and libstdc++ References: <53F24D45.9090604@gmail.com> In-Reply-To: <53F24D45.9090604@gmail.com> X-Forwarded-Message-Id: <53F24D45.9090604@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2ccjud7cBCH5L9EveFCSKLaKn1q1J0uJG" X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00117.txt.bz2 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2ccjud7cBCH5L9EveFCSKLaKn1q1J0uJG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 2650 On 18.8.2014 13:25, Jonathan Wakely wrote: > I'm on my phone so can't send plain text mail to the list, or check the > code, but I'm pretty sure the answer is 101 >=20 > Anything lower than that is reserved for the implementation so libstdc++ > would use that. Nothing in string or vector needs dynamic init anyway IIRC Some paths of my library's initialization might try to print warnings or errors. I have hit a SIGSEGV with the following test case, which uses std::cerr: ~~~~ #include struct S1 { S1() { std::cerr << __FUNCTION__ << "\n"; } } static s1 __attribute__ ((__init_priority__ (65535/2))); int main () { return 0; } ~~~~ The stack trace is ~~~~ #0 0x00007ffff7b6a559 in std::ostream::sentry::sentry(std::ostream&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #1 0x00007ffff7b6ac19 in std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #2 0x00007ffff7b6b077 in std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #3 0x000000000040081d in S1::S1 (this=3D0x601172 ) at test.cxx:5 #4 0x00000000004007d6 in __static_initialization_and_destruction_0 (__initialize_p=3D1, __priority=3D32767) at test.cxx:6 #5 0x00000000004007eb in _GLOBAL__sub_I.32767_main(void) () at test.cxx:13 #6 0x000000000040087d in __libc_csu_init () #7 0x00007ffff7731e55 in __libc_start_main (main=3D0x40077d , argc=3D1, argv=3D0x7fffffffe2c8, init=3D0x400830 <__libc_csu_init>, fini=3D, rtld_fini=3D, stack_end=3D0x7fffffffe2b8) at libc-start.c:246 #8 0x00000000004006b9 in _start () ~~~~ Is this expected? >=20 > On Aug 17, 2014 8:56 PM, "V=C3=A1clav Zeman" > wrote: >=20 > Hi. >=20 > I want to use the init_priority(prio) attribute > (https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html#C_002= b_002b-Attributes) > to initialize stuff in my library early so that users of the library = can > use the library during their own static objects construction. However, > my library uses standard C++ library facilities like std::string, > std::vector<>, etc. The question is: >=20 > What is the lowest priority for init_priority attribute that I can use > to still have libstdc++ initialize itself before my library is > initialized? --=20 VZ --2ccjud7cBCH5L9EveFCSKLaKn1q1J0uJG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 230 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iF4EAREKAAYFAlPyTksACgkQonnuNA9W3VJmDgD+JiMF175Y4IHro5cSte5OhZWb BjfAbPECiqxcUiisUJsA/R8JZ9IYNoYxB6bFChU/GkAqHXaRytGi99KVSEvmzyud =Nxet -----END PGP SIGNATURE----- --2ccjud7cBCH5L9EveFCSKLaKn1q1J0uJG--