Bug 670984

Summary: C++ compiler crashes during compilation some source code
Product: [Fedora] Fedora Reporter: Vyacheslav Ignatyuk <slava>
Component: gcc4Assignee: Jakub Jelinek <jakub>
Status: CLOSED UPSTREAM QA Contact:
Severity: high Docs Contact:
Priority: low    
Version: 14   
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-01-21 14:43:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
test source code to reproduce bug none

Description Vyacheslav Ignatyuk 2011-01-19 20:38:35 UTC
Description of problem:
Compiler crashes with "internal compiler error: Segmentation fault" at the same place.

Version-Release number of selected component (if applicable):
bash-4.1$ cat /etc/issue
Fedora release 14 (Laughlin)
Kernel \r on an \m (\l)

bash-4.1$ uname -a
Linux devlin 2.6.35.10-74.fc14.x86_64 #1 SMP Thu Dec 23 16:04:50 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

bash-4.1$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.5.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC) 


How reproducible:
Attachment contains preprocessed project's source code. Compilation using simple "g++ source.cpp" always crashes.

Steps to Reproduce:
1. save attachments file as "source.cpp"
2. run "g++ source.cpp"
3. see result
  
Actual results:
bash-4.1$ g++ source.cpp 
In file included from ../../include/qpp/cdb/cdb.h:739:0,
                 from src/cdbget.cpp:6:
../../include/qpp/cdb/cdb.tcc: In member function ‘void cdb::cdb<Key, Value, SizeOfOffsetType, SizeOfSizeType, SizeOfLengthType, Hasher, KayTraits, ValueTraits, Comparator, -0x00000000000000001>::init() [with Key = std::basic_string<char>, Value = std::pair<cdb::io::input_iterator<4>, cdb::io::input_iterator<4> >, int SizeOfOffsetType = 4, int SizeOfSizeType = 4, int SizeOfLengthType = 4, Hasher = cdb::hash::djb<4>, KayTraits = cdb::type_traits<std::basic_string<char> >, ValueTraits = cdb::type_traits<std::pair<cdb::io::input_iterator<4>, cdb::io::input_iterator<4> > >, Comparator = cdb::comparator]’:
../../include/qpp/cdb/cdb.tcc:365:2:   instantiated from ‘cdb::cdb<Key, Value, SizeOfOffsetType, SizeOfSizeType, SizeOfLengthType, Hasher, KayTraits, ValueTraits, Comparator, -0x00000000000000001>::cdb(cdb::io::descriptor) [with Key = std::basic_string<char>, Value = std::pair<cdb::io::input_iterator<4>, cdb::io::input_iterator<4> >, int SizeOfOffsetType = 4, int SizeOfSizeType = 4, int SizeOfLengthType = 4, Hasher = cdb::hash::djb<4>, KayTraits = cdb::type_traits<std::basic_string<char> >, ValueTraits = cdb::type_traits<std::pair<cdb::io::input_iterator<4>, cdb::io::input_iterator<4> > >, Comparator = cdb::comparator]’
src/cdbget.cpp:33:40:   instantiated from here
../../include/qpp/cdb/cdb.tcc:351:2: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.


Expected results:
no errors

Additional info:
1) increased size of stack did not help;
2) valgrind complained about invalid read from the address 0x3. Address is always the same "0x3" each time I ran compilation. Not sure what is not right in particular but it looks like invalid pointer dereferencing but why?
Part of valgrind's output related to the error is below.

==22153== Invalid read of size 2
==22153==    at 0x679A78: tsubst (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x67D668: tsubst_copy_and_build (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x6747BC: ??? (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x67BCAF: ??? (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x67A433: tsubst (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x67D668: tsubst_copy_and_build (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x67D4C5: tsubst_copy_and_build (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x6747BC: ??? (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x67BCAF: ??? (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x679515: ??? (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x67C378: ??? (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==    by 0x67E2AD: tsubst_copy_and_build (in /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1plus)
==22153==  Address 0x3 is not stack'd, malloc'd or (recently) free'd

Comment 1 Jakub Jelinek 2011-01-20 13:57:31 UTC
You haven't attached any (preprocessed) testcase here.

Comment 2 Vyacheslav Ignatyuk 2011-01-20 17:56:42 UTC
Created attachment 474508 [details]
test source code to reproduce bug

For unknown reason test source was not uploaded during original submission.

Comment 3 Vyacheslav Ignatyuk 2011-01-20 17:59:05 UTC
(In reply to comment #1)
> You haven't attached any (preprocessed) testcase here.

I attached it originally. Don't know what happened at the submission time but I added attachment and I see it is here.

Comment 4 Jakub Jelinek 2011-01-21 14:43:37 UTC
Tracking upstream.