Bug 65638 - Crash on invalid input
Summary: Crash on invalid input
Status: RESOLVED DUPLICATE of bug 61977
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-31 12:14 UTC by James Michael DuPont
Modified: 2015-03-31 16:37 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc64le-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-03-31 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Michael DuPont 2015-03-31 12:14:24 UTC
using the invalid input file:
```
void crash (bool
```

found using permutation testing based on the 
https://h4ck3rm1k3.wordpress.com/2015/03/31/test-random-permutations-of-files-and-lines-for-gccgo-golang-go-compiler-bug-reporting/

Arch:
Linux gcc2-power8.osuosl.org 3.17.4-301.fc21.ppc64le #1 SMP Mon Dec 1 07:51:01 UTC 2014 ppc64le ppc64le ppc64le GNU/Linux

crashes on :
gcc (GCC) 4.9.2 20141101 (Red Hat 4.9.2-1)
and
gcc (GCC) 5.0.0 20150331 (experimental)
but not on :

Linux 3.10-1-amd64 #1 SMP Debian 3.10.3-1 (2013-07-27) x86_64 GNU/Linux
with g++-4.9 (Debian 4.9.2-10) 4.9.2


```
test.cc:1:14: error: expected ‘,’ or ‘...’ at end of input
 void crash ( bool
              ^
test.cc:1:14: error: expected ‘)’ at end of input
test.cc:1:14: error: expected initializer at end of input
```
Comment 1 Marek Polacek 2015-03-31 12:21:48 UTC
This doesn't crash for me with 4.8/4.9 nor 5; what options did you use?
Comment 2 James Michael DuPont 2015-03-31 12:24:58 UTC
No options at all.
On the gcc compile farm : gcc112.fsffrance.org


[h4ck3rm1k3@gcc2-power8 ~]$ which g++
/usr/bin/g++
[h4ck3rm1k3@gcc2-power8 ~]$ g++ test1.cc
test1.cc:1:1: internal compiler error: Segmentation fault
 void crash ( bool
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Comment 3 James Michael DuPont 2015-03-31 12:38:25 UTC
This test case can be reduced to just a file with the word bool in it.

```
bool
```
Comment 4 Markus Trippelsdorf 2015-03-31 12:43:01 UTC
trippels@gcc2-power8 ~ % echo "bool" | /home/trippels/gcc_valgrind/usr/local/bin/g++ -x c++ -
==12604== Invalid read of size 1
==12604==    at 0x10D99290: _cpp_lex_direct (lex.c:2279)
==12604==    by 0x10D9A6F7: _cpp_lex_token (lex.c:2163)
==12604==    by 0x10DA1147: cpp_get_token_1(cpp_reader*, unsigned int*) (macro.c:2442)
==12604==    by 0x102E2FB3: c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int) (c-lex.c:408)
==12604==    by 0x101B235B: cp_lexer_get_preprocessor_token(cp_lexer*, cp_token*) (parser.c:780)
==12604==    by 0x101F36A7: cp_lexer_new_main (parser.c:660)
==12604==    by 0x101F36A7: cp_parser_new (parser.c:3484)
==12604==    by 0x101F36A7: c_parse_file() (parser.c:33187)
==12604==    by 0x102E952B: c_common_parse_file() (c-opts.c:1057)
==12604==    by 0x107688AB: compile_file() (toplev.c:594)
==12604==    by 0x10111D33: do_compile (toplev.c:2076)
==12604==    by 0x10111D33: toplev::main(int, char**) (toplev.c:2174)
==12604==    by 0x10112747: main (main.c:39)
==12604==  Address 0x68 is not stack'd, malloc'd or (recently) free'd
==12604== 
<stdin>:1:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 5 Martin Sebor 2015-03-31 16:25:34 UTC
Replacing "bool" with "vector" also leads to an ICE.  Perhaps this is the same issue as pr61977.
Comment 6 Markus Trippelsdorf 2015-03-31 16:37:27 UTC
(In reply to Martin Sebor from comment #5)
> Replacing "bool" with "vector" also leads to an ICE.  Perhaps this is the
> same issue as pr61977.

Yes.

*** This bug has been marked as a duplicate of bug 61977 ***