Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

[ICE] More cycle detection gone wrong #312

Closed
jyn514 opened this issue Feb 29, 2020 · 0 comments · Fixed by #359
Closed

[ICE] More cycle detection gone wrong #312

jyn514 opened this issue Feb 29, 2020 · 0 comments · Fixed by #359
Labels
bug Something isn't working ICE Internal Compiler Error (panic) preprocessor Issue in the preprocessor (probably cycle detection)

Comments

@jyn514
Copy link
Owner

jyn514 commented Feb 29, 2020

Expected behavior
RCC should detect the cycle and replace f only one time.

Actual Behavior
RCC recurses forever and segfaults.

Code

#define f(a) f(1 + 2)
f(1)

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)
Backtrace
(gdb) where
#0  0x00005555557f2e1a in rcc::lex::cpp::PreProcessor::replace_function (
    self=<error reading variable: Cannot access memory at address 0x7fffff7feb30>, 
    name=<error reading variable: Cannot access memory at address 0x7fffff7feb38>, 
    start=<error reading variable: Cannot access memory at address 0x7fffff7feb3c>)
    at src/lex/cpp.rs:595
#1  0x00005555557f2c13 in rcc::lex::cpp::PreProcessor::replace_id (
    self=0x7fffffffa1f8, name=..., location=...) at src/lex/cpp.rs:593
#2  0x00005555557ef4cd in rcc::lex::cpp::PreProcessor::handle_token (
    self=0x7fffffffa1f8, token=..., location=...) at src/lex/cpp.rs:243
#3  0x00005555557edac3 in <rcc::lex::cpp::PreProcessor as core::iter::traits::iterator::Iterator>::next (self=0x7fffffffa1f8) at src/lex/cpp.rs:141
#4  0x00005555557f38f7 in rcc::lex::cpp::PreProcessor::replace_function (
    self=0x7fffffffa1f8, name=..., start=26) at src/lex/cpp.rs:657
#5  0x00005555557f2c13 in rcc::lex::cpp::PreProcessor::replace_id (
    self=0x7fffffffa1f8, name=..., location=...) at src/lex/cpp.rs:593
#6  0x00005555557ef4cd in rcc::lex::cpp::PreProcessor::handle_token (
    self=0x7fffffffa1f8, token=..., location=...) at src/lex/cpp.rs:243
...
#3946 0x00005555557ef4cd in rcc::lex::cpp::PreProcessor::handle_token (
    self=0x7fffffffa1f8, token=..., location=...) at src/lex/cpp.rs:243
#3947 0x00005555557ee074 in <rcc::lex::cpp::PreProcessor as core::iter::traits::iterator::Iterator>::next (self=0x7fffffffa1f8) at src/lex/cpp.rs:154
#3948 0x00005555557a2402 in rcc::compile (buf=..., opt=0x7fffffffd538, file=..., 
    files=0x7fffffffd920) at src/lib.rs:161
#3949 0x00005555555faa88 in rcc::real_main (buf=..., file_db=0x7fffffffd920, 
    file_id=..., opt=0x7fffffffd538, output=0x55555612cdb0) at src/main.rs:110
#3950 0x00005555555fc312 in rcc::main () at src/main.rs:176
@jyn514 jyn514 added bug Something isn't working ICE Internal Compiler Error (panic) preprocessor Issue in the preprocessor (probably cycle detection) labels Feb 29, 2020
jyn514 added a commit that referenced this issue Mar 26, 2020
jyn514 added a commit that referenced this issue Mar 26, 2020
jyn514 added a commit that referenced this issue Feb 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working 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