[GiNaC-list] [(Possible) Bug Report] g++-4.8 (slightly) breaks GiNaC::symbol

Richard B. Kreckel kreckel at ginac.de
Mon Mar 25 20:23:41 CET 2013


Hey,

On 03/25/2013 03:34 AM, Song Gao wrote:
> I had a weird problem using GiNaC with g++-4.8. It seems that
> GiNac::symbol will be deleted twice if it's not dynamically declared.
> In other words, some resources in it is free'd before the automatic
> destructor is called when the scope finishes.
>
> The minimum code to re-produce the issue is:
>
> #include <ginac/ginac.h>
>
> int main() {
>      GiNaC::symbol x("x");
>      return 0;
> }
>
> $ g++-4.8 -g -o main main0.cc -lginac -lcln && ./main
> main(69018) malloc: *** error for object 0x7fff73275570: pointer being
> freed was not allocated
>
>
> It seems this issue only exists in g++-4.8. g++-4.7 is fine.
>
> I briefly looked at symbol.h but did not manage to locate the problem.
> I was hoping someone here more familiar with the code base could fix
> it or provide some direction for me. Thanks.
>
> --
> Song Gao
> http://song.gao.io/

I just bootstrapped gcc 4.8 and compiled and ran your example without 
problem. Also, it passes all tests of the test suite, both for a static 
and dynamic library.

For reference, and to help you experiment further, here is my setup:
$ gcc-4.8 -v
Using built-in specs.
COLLECT_GCC=gcc-4.8
COLLECT_LTO_WRAPPER=/data/scratch/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.0-RC-20130316/configure 
--enable-languages=c,c++ --prefix=/data/scratch --program-suffix=-4.8 
--enable-shared --enable-linker-build-id --with-system-zlib 
--disable-nls --enable-checking=release
Thread model: posix
gcc version 4.8.0 20130316 (prerelease) (GCC)

   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>


More information about the GiNaC-list mailing list