public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65209] New: [5.0 regression] Broken code with global static variables, invalid pointer when freeing global variables
@ 2015-02-25 15:34 manisandro at gmail dot com
  2015-02-25 15:50 ` [Bug c++/65209] [5 Regression] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: manisandro at gmail dot com @ 2015-02-25 15:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65209

            Bug ID: 65209
           Summary: [5.0 regression] Broken code with global static
                    variables, invalid pointer when freeing global
                    variables
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manisandro at gmail dot com

Created attachment 34870
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34870&action=edit
testcase

Using gcc-5.0.0-0.15.fc23.x86_64

Test case attached. Build with

$ g++ -g -Wall -o main foo.cpp main.cpp

The test case crashes when freeing global variables:

./main
*** Error in `/home/sandro/Desktop/a/main': free(): invalid pointer:
0x0000000000610001 ***


#0  0x00007ffff71a6ae8 in raise () from /lib64/libc.so.6
#1  0x00007ffff71a877a in abort () from /lib64/libc.so.6
#2  0x00007ffff71eb092 in __libc_message () from /lib64/libc.so.6
#3  0x00007ffff71f2994 in _int_free () from /lib64/libc.so.6
#4  0x00007ffff71f748c in free () from /lib64/libc.so.6
#5  0x000000000040099b in FooData::~FooData (this=0x602118
<_ZGVZN12_GLOBAL__N_112Q_QGS_s_self13innerFunctionEvE6holder>,
__in_chrg=<optimized out>)
    at foo.cpp:5
#6  0x00000000004009da in Foo::~Foo (this=0x602100
<_ZZN12_GLOBAL__N_112Q_QGS_s_self13innerFunctionEvE6holder>,
__in_chrg=<optimized out>) at foo.cpp:8
#7  0x0000000000400a12 in FooSingleton::~FooSingleton (this=0x602100
<_ZZN12_GLOBAL__N_112Q_QGS_s_self13innerFunctionEvE6holder>, 
    __in_chrg=<optimized out>) at foo.cpp:15
#8  0x0000000000400a69 in (anonymous
namespace)::Q_QGS_s_self::innerFunction()::Holder::~Holder() (
    this=0x602100 <_ZZN12_GLOBAL__N_112Q_QGS_s_self13innerFunctionEvE6holder>,
__in_chrg=<optimized out>) at foo.cpp:33
#9  0x00007ffff71ab628 in __run_exit_handlers () from /lib64/libc.so.6
#10 0x00007ffff71ab675 in exit () from /lib64/libc.so.6
#11 0x00007ffff7191847 in __libc_start_main () from /lib64/libc.so.6
#12 0x00000000004007e9 in _start ()


Observations:
- Depends on the Q_QGS_s_self namespace being called such (more precisely,
exactly such, not even any other name with equal length)
- Depends on the innerFunction method being called such
- Depends on innerFunction being inline
- Depends on the size of the global variables


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

end of thread, other threads:[~2015-03-04 18:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-25 15:34 [Bug c++/65209] New: [5.0 regression] Broken code with global static variables, invalid pointer when freeing global variables manisandro at gmail dot com
2015-02-25 15:50 ` [Bug c++/65209] [5 Regression] " rguenth at gcc dot gnu.org
2015-02-25 16:54 ` manisandro at gmail dot com
2015-02-25 18:21 ` jakub at gcc dot gnu.org
2015-02-25 23:13 ` jason at gcc dot gnu.org
2015-02-26  2:44 ` jakub at gcc dot gnu.org
2015-03-04 18:14 ` jason 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).