https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64371
Bug ID: 64371 Summary: 'stack smashing detected' in my code (NumStringConv). Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: matszpk at interia dot pl I tried to run my program for conversion from numbers to strings (called as NumStringConv). Unhappilly, a testing program 'cstrtofXTest' causes 'stack smashing detected'. cstrtofXTest tests 'NumStringConv.cpp' code and that code causes (very likely) bug in GCC. Program has been compiled for i686 architecture under Gentoo Linux with "gcc (Gentoo 4.9.2 p1.0, pie-0.6.1) 4.9.2" and glibc 2.20 with debuginfo. GCC has been configured with: Using built-in specs. COLLECT_GCC=/usr/i686-pc-linux-gnu/gcc-bin/4.9.2/g++ Target: i686-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.9.2/work/gcc-4.9.2/configure --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.9.2 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.9.2 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.9.2/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.9.2/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.9.2/include/g++-v4 --with-python-dir=/share/gcc-data/i686-pc-linux-gnu/4.9.2/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.9.2 p1.0, pie-0.6.1' --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-altivec --disable-fixed-point --with-arch=i686 --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --enable-lto --with-cloog --disable-isl-version-check --enable-libsanitizer Thread model: posix gcc version 4.9.2 (Gentoo 4.9.2 p1.0, pie-0.6.1) Source codes for program available at "https://github.com/matszpk/NumStringConv". All compilations flags are in Makefile (I did not change content while compilation). There flags are: -Wall -std=gnu++11 -O2. Bug has been reproduced with flags '-Wall -std=gnu++11 -g' (without optimizations). Program was compiled without any warnings. I attach backtrace: *** stack smashing detected ***: ./cstrtofXTest terminated ======= Backtrace: ========= /lib/libc.so.6(+0x6da3a)[0xb7521a3a] /lib/libc.so.6(__fortify_fail+0x45)[0xb75b3415] /lib/libc.so.6(+0xff3ca)[0xb75b33ca] ./cstrtofXTest[0x8050df5] ./cstrtofXTest[0x80515e8] ./cstrtofXTest[0x804968e] /lib/libc.so.6(__libc_start_main+0xf2)[0xb74cbe12] ./cstrtofXTest[0x80499f9] ======= Memory map: ======== 08048000-08061000 r-xp 00000000 08:01 765390 /home/mat/docs/src/NumStringConv-master/cstrtofXTest 08061000-08062000 r--p 00018000 08:01 765390 /home/mat/docs/src/NumStringConv-master/cstrtofXTest 08062000-08063000 rw-p 00019000 08:01 765390 /home/mat/docs/src/NumStringConv-master/cstrtofXTest 097ca000-097eb000 rw-p 00000000 00:00 0 [heap] b74b1000-b74b4000 rw-p 00000000 00:00 0 b74b4000-b764a000 r-xp 00000000 08:01 1912875 /lib/libc-2.20.so b764a000-b764d000 r--p 00195000 08:01 1912875 /lib/libc-2.20.so b764d000-b764f000 rw-p 00198000 08:01 1912875 /lib/libc-2.20.so b764f000-b7651000 rw-p 00000000 00:00 0 b7651000-b766c000 r-xp 00000000 08:01 1534035 /usr/lib/gcc/i686-pc-linux-gnu/4.9.2/libgcc_s.so.1 b766c000-b766d000 r--p 0001a000 08:01 1534035 /usr/lib/gcc/i686-pc-linux-gnu/4.9.2/libgcc_s.so.1 b766d000-b766e000 rw-p 0001b000 08:01 1534035 /usr/lib/gcc/i686-pc-linux-gnu/4.9.2/libgcc_s.so.1 b766e000-b76b2000 r-xp 00000000 08:01 1913171 /lib/libm-2.20.so b76b2000-b76b3000 r--p 00043000 08:01 1913171 /lib/libm-2.20.so b76b3000-b76b4000 rw-p 00044000 08:01 1913171 /lib/libm-2.20.so b76b4000-b779b000 r-xp 00000000 08:01 1534281 /usr/lib/gcc/i686-pc-linux-gnu/4.9.2/libstdc++.so.6.0.20 b779b000-b779f000 r--p 000e7000 08:01 1534281 /usr/lib/gcc/i686-pc-linux-gnu/4.9.2/libstdc++.so.6.0.20 b779f000-b77a0000 rw-p 000eb000 08:01 1534281 /usr/lib/gcc/i686-pc-linux-gnu/4.9.2/libstdc++.so.6.0.20 b77a0000-b77a7000 rw-p 00000000 00:00 0 b77b8000-b77ba000 rw-p 00000000 00:00 0 b77ba000-b77db000 r-xp 00000000 08:01 1913430 /lib/ld-2.20.so b77db000-b77dc000 r--p 00020000 08:01 1913430 /lib/ld-2.20.so b77dc000-b77dd000 rw-p 00021000 08:01 1913430 /lib/ld-2.20.so bfef4000-bff16000 rw-p 00000000 00:00 0 [stack] Przerwane (zrzut pamięci) Attachment in report is preprocessed file for analysis (for NumStringConv.cpp). Any response or solution will be appreciated. Sorry for my english.