Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[ICE] preprocessor needs a recursion guard #399

Closed
jyn514 opened this issue May 3, 2020 · 0 comments · Fixed by #428
Closed

[ICE] preprocessor needs a recursion guard #399

jyn514 opened this issue May 3, 2020 · 0 comments · Fixed by #428
Labels
fuzz Found via fuzz testing ICE Internal Compiler Error (panic) preprocessor Issue in the preprocessor (probably cycle detection)

Comments

@jyn514
Copy link
Owner

jyn514 commented May 3, 2020

Code

Modified from the gcc torture suite.

/* Add a few "extern int Xxxxxx ();" declarations.  */
#define LIM1(x) x##0, x##1, x##2, x##3, x##4, x##5, x##6, x##7, x##8, x##9,
#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \
                LIM1(##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)
#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \
                (##7) LIM2(x##8) LIM2(x##9)
#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \
                (##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)
#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \
                (((##) LIM6(x##6) LIM6(x##7) LIM6(x##8) LIM6(x##9)

(LIM5())
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)

Expected behavior

It should give a fatal error and exit normally, like for nested expressions.

Backtrace
(gdb) where
#0  0x00005555559f9cfa in rcc::lex::cpp::PreProcessor::replace_function (
    self=0xc42342f8aa7b0cd, 
    name=<error reading variable: Cannot access memory at address 0x7fffff7fecf8>, 
    start=<error reading variable: Cannot access memory at address 0x7fffff7fecfc>)
    at src/lex/cpp.rs:709
#1  0x00005555559f9ae9 in rcc::lex::cpp::PreProcessor::replace_id (
    self=0x7fffffff9710, name=..., location=...) at src/lex/cpp.rs:707
#2  0x00005555559f695c in rcc::lex::cpp::PreProcessor::handle_token (
    self=0x7fffffff9710, token=..., location=...) at src/lex/cpp.rs:354
#3  0x00005555559fac88 in rcc::lex::cpp::PreProcessor::replace_function (
    self=0x7fffffff9710, name=..., start=567) at src/lex/cpp.rs:787
#4  0x00005555559f9ae9 in rcc::lex::cpp::PreProcessor::replace_id (
    self=0x7fffffff9710, name=..., location=...) at src/lex/cpp.rs:707
... several thousand more lines ...
@jyn514 jyn514 added ICE Internal Compiler Error (panic) preprocessor Issue in the preprocessor (probably cycle detection) fuzz Found via fuzz testing labels May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fuzz Found via fuzz testing ICE Internal Compiler Error (panic) preprocessor Issue in the preprocessor (probably cycle detection)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant