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

[ICE] Macro expansion assertion failed #496

Open
pythongirl325 opened this issue Aug 8, 2020 · 3 comments
Open

[ICE] Macro expansion assertion failed #496

pythongirl325 opened this issue Aug 8, 2020 · 3 comments
Labels
fuzz Found via fuzz testing ICE Internal Compiler Error (panic) preprocessor Issue in the preprocessor (probably cycle detection)

Comments

@pythongirl325
Copy link
Collaborator

Code

#define T()
T( ` )

Message:

The application panicked (crashed).
Message:  assertion failed: !matches!(args . last(), Some(Token :: Whitespace(_)))
Location: src/lex/replace.rs:280

Expected behavior

Error saying that ``` is an invalid character. (probably)

Backtrace
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/swcc --color=never test.c`
The application panicked (crashed).
Message:  assertion failed: !matches!(args . last(), Some(Token :: Whitespace(_)))
Location: src/lex/replace.rs:280

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                              ⋮ 4 frames hidden ⋮                               
 5: saltwater::lex::replace::replace_function::strip_whitespace::h8309bcbb0f143edb
    at /home/gis/code/saltwater/src/lex/replace.rs:280
 6: saltwater::lex::replace::replace_function::h8e25009758ae6d78
    at /home/gis/code/saltwater/src/lex/replace.rs:314
 7: saltwater::lex::replace::replace::h7406a37dc332f835
    at /home/gis/code/saltwater/src/lex/replace.rs:180
 8: saltwater::lex::cpp::PreProcessor::handle_token::h4da91e8f99457e00
    at /home/gis/code/saltwater/src/lex/cpp.rs:284
 9: <saltwater::lex::cpp::PreProcessor as core::iter::traits::iterator::Iterator>::next::h7a2ccc5f7a2d0518
    at /home/gis/code/saltwater/src/lex/cpp.rs:248
10: <&mut I as core::iter::traits::iterator::Iterator>::next::hd5551b5762e8a36f
    at /home/gis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/traits/iterator.rs:3258
11: <core::iter::adapters::Peekable<I> as core::iter::traits::iterator::Iterator>::next::h213360103a6abc02
    at /home/gis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/adapters/mod.rs:1399
12: saltwater::parse::Parser<I>::__impl_next_token::hfeaf52746f7445bb
    at /home/gis/code/saltwater/src/parse/mod.rs:142
13: saltwater::parse::Parser<I>::peek_token::{{closure}}::ha9891d931dfc1b39
    at /home/gis/code/saltwater/src/parse/mod.rs:207
14: core::option::Option<T>::or_else::h56d9ccafaa98794f
    at /home/gis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/option.rs:766
15: saltwater::parse::Parser<I>::peek_token::h89c2a9f52cf73082
    at /home/gis/code/saltwater/src/parse/mod.rs:207
16: <saltwater::parse::Parser<I> as core::iter::traits::iterator::Iterator>::next::h01b34dec7d042a69
    at /home/gis/code/saltwater/src/parse/mod.rs:107
17: <saltwater::analyze::Analyzer<T> as core::iter::traits::iterator::Iterator>::next::hb7aae02eae7cfe74
    at /home/gis/code/saltwater/src/analyze/mod.rs:95
18: <&mut I as core::iter::traits::iterator::Iterator>::next::h6ccd91b5947a96bc
    at /home/gis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/traits/iterator.rs:3258
19: saltwater::check_semantics::ha40a786b537cf457
    at /home/gis/code/saltwater/src/lib.rs:240
20: saltwater::compile::hf9937d5e5682c4bb
    at /home/gis/code/saltwater/src/lib.rs:271
21: swcc::aot_main::h6585910bd9a711ec
    at /home/gis/code/saltwater/src/main.rs:172
22: swcc::real_main::h4a7b3b4b2e8a6631
    at /home/gis/code/saltwater/src/main.rs:161
23: swcc::main::h680d2fa7efb5314a
    at /home/gis/code/saltwater/src/main.rs:273
                              ⋮ 10 frames hidden ⋮                              
@pythongirl325 pythongirl325 added ICE Internal Compiler Error (panic) preprocessor Issue in the preprocessor (probably cycle detection) fuzz Found via fuzz testing labels Aug 8, 2020
@hdamron17
Copy link
Collaborator

The expected behavior of ` being an invalid character is true for running in general, but if you run with -E it should go through. Unfortunately, lexer tokens are parsed before the preprocessor at the moment so some things which should be fine with -E still give a lexer error if the token is invalid. See #395.

@pythongirl325
Copy link
Collaborator Author

pythongirl325 commented Aug 8, 2020

This was originally found with the character \x1f in place of the backquote, but i found that the tilde produced the same crash, I don't know if that helps, but a little more info.

@hdamron17
Copy link
Collaborator

What if you do something with a valid lever token? I think the issue is just that there's nothing after the macro name and so when it asserts that it's stripped whitespace off the definition, there's nothing left and it's confused.

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

No branches or pull requests

2 participants