public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/46097] New: Switch to warn of global variables in a C++ shared object
@ 2010-10-20 14:35 noloader at gmail dot com
  2010-10-20 15:53 ` [Bug c++/46097] " redi at gcc dot gnu.org
                   ` (30 more replies)
  0 siblings, 31 replies; 32+ messages in thread
From: noloader at gmail dot com @ 2010-10-20 14:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46097

           Summary: Switch to warn of global variables in a C++ shared
                    object
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: noloader@gmail.com


Feature reqeust only. Not a bug.

C++ shared objects are an interesting beast under certain circumstances (many
times, the shared object acts like a generic C module). Interesting includes:
* C++ module
* Shared object
* Shared object throws an exception which will cross module boundaries
* Shared object opened with RTLD_GLOBAL
* Shared object has global objects with destructors

Lots have been said about C++ exceptions, RTTI, type equality for the
'catch(const Exception&)', and RTLD_GLOBAL (versus RTLD_LOCAL) [1,2,3,4,5].

When a module meets the above compile and runtime requirements, a crash can
occur in global objects with destructors when more than one process loads and
subsequently unloads a shared object.

A switch to warn of global variables in a compilation unit would be very
helpful for those who are aware of the issue (and the circumstances to
encounter the issue). It appears that GCC does not supply such a switch [6].

The switch would be useful for module writers since its not always feasible to
'hand audit' all project files. And a warning would be exetremely useful for
package maintainers who don't write the module - they simply fixup the code and
package it for a distribution.

Perhaps -Wglobal-variable?

Jeffrey Walton
Baltimore, MD, US

[1] Minimal GCC/Linux shared lib + EH bug example,
http://gcc.gnu.org/ml/gcc/2002-05/msg00866.html
[2] dlopen and placing exception body in .cpp file,
http://gcc.gnu.org/ml/gcc-help/2010-08/msg00290.html
[3] Comparing types across SOs (sic),
http://groups.google.com/group/cryptopp-users/browse_thread/thread/eb815f228db50380
[4] Errors with multiple loading cryptopp as shared lib on Linux,
http://groups.google.com/group/cryptopp-users/browse_thread/thread/68fbc22e8c6e2f48
[5] RTLD_GLOBAL and libcryptopp.so crash,
http://groups.google.com/group/cryptopp-users/browse_thread/thread/7eae009a4e02e726
[6] Audit Use of Global Variables in C++ Shared Object (GCC Warning?), GCC-Help
mailing list, October, 2010 [not yet indexed].


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

end of thread, other threads:[~2010-10-22 23:56 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-20 14:35 [Bug c++/46097] New: Switch to warn of global variables in a C++ shared object noloader at gmail dot com
2010-10-20 15:53 ` [Bug c++/46097] " redi at gcc dot gnu.org
2010-10-20 17:34 ` noloader at gmail dot com
2010-10-20 17:39 ` noloader at gmail dot com
2010-10-20 22:46 ` redi at gcc dot gnu.org
2010-10-20 22:48 ` redi at gcc dot gnu.org
2010-10-20 23:18 ` noloader at gmail dot com
2010-10-20 23:48 ` redi at gcc dot gnu.org
2010-10-21  2:01 ` noloader at gmail dot com
2010-10-21 15:04 ` noloader at gmail dot com
2010-10-21 15:17 ` redi at gcc dot gnu.org
2010-10-21 15:22 ` redi at gcc dot gnu.org
2010-10-21 15:28 ` redi at gcc dot gnu.org
2010-10-21 16:11 ` noloader at gmail dot com
2010-10-21 16:13 ` noloader at gmail dot com
2010-10-21 16:15 ` noloader at gmail dot com
2010-10-21 16:24 ` redi at gcc dot gnu.org
2010-10-21 17:00 ` noloader at gmail dot com
2010-10-21 17:37 ` noloader at gmail dot com
2010-10-21 18:41 ` redi at gcc dot gnu.org
2010-10-21 18:47 ` redi at gcc dot gnu.org
2010-10-21 18:50 ` noloader at gmail dot com
2010-10-21 18:54 ` pinskia at gcc dot gnu.org
2010-10-21 19:52 ` noloader at gmail dot com
2010-10-22  1:59 ` noloader at gmail dot com
2010-10-22  5:52 ` noloader at gmail dot com
2010-10-22  7:35 ` redi at gcc dot gnu.org
2010-10-22  7:38 ` noloader at gmail dot com
2010-10-22 19:49 ` noloader at gmail dot com
2010-10-22 20:37 ` redi at gcc dot gnu.org
2010-10-22 23:49 ` ian at airs dot com
2010-10-22 23:56 ` ian at airs dot com

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