ethereum / fe

Emerging smart contract language for the Ethereum blockchain.
https://fe-lang.org
Other
1.62k stars 188 forks source link

'internal error: entered unreachable code', crates/parser/src/lexer/token.rs:304:22 #623

Open agroce opened 2 years ago

agroce commented 2 years ago

Compiling this file:

contract o
 pub def r(z:u256)
  ''.t
Warning: bytecode output requires 'solc-backend' feature. Try `cargo build --release --features solc-backend`. Skipping.
thread 'main' panicked at 'internal error: entered unreachable code', crates/parser/src/lexer/token.rs:304:22
stack backtrace:
   0:     0x55b82e7e94cc - std::backtrace_rs::backtrace::libunwind::trace::hf6a6dfd7da937cb0
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x55b82e7e94cc - std::backtrace_rs::backtrace::trace_unsynchronized::hc596a19e4891f7f3
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55b82e7e94cc - std::sys_common::backtrace::_print_fmt::hb16700db31584325
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x55b82e7e94cc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h231c4190cfa75162
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x55b82e80691c - core::fmt::write::h2a1462b5f8eea807
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/fmt/mod.rs:1163:17
   5:     0x55b82e7e6095 - std::io::Write::write_fmt::h71ddfebc68685972
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/io/mod.rs:1696:15
   6:     0x55b82e7eaf30 - std::sys_common::backtrace::_print::hcc197d4bebf2b369
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x55b82e7eaf30 - std::sys_common::backtrace::print::h335a66af06738c7c
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x55b82e7eaf30 - std::panicking::default_hook::{{closure}}::h6fac9ac9c8b79e52
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:210:50
   9:     0x55b82e7eaae5 - std::panicking::default_hook::h341c1030c6a1161b
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:227:9
  10:     0x55b82e73bc2f - fe_common::panic::report_ice::h3873cf98d32e7b02

You've hit an internal compiler error. This is a bug in the Fe compiler.
Fe is still under heavy development, and isn't yet ready for production use.

If you would, please report this bug at the following URL:
  https://github.com/ethereum/fe/issues/new
Aborted

Using

[profile.dev]
debug = true
panic = "abort"

for fuzzing. Using https://github.com/agroce/afl-compiler-fuzzer

agroce commented 2 years ago

Note I'm not running solc, right now, the backend is having issues building for me, and this ups throughput on the front analysis anyway.

agroce commented 2 years ago

The previously fixed

contract r:
 pub fn t():
  []

also fails, BTW, maybe related?

cburgdorf commented 2 years ago

I can not reproduce the crash of the first snippet on latest master (f151b532)

$ git lg -n1
* f151b532 (HEAD -> master, upstream/master) Allow address-to-u256 cast (#621)
cburgdorf at snakebot in ~/Documents/hacking/ef/fe on master*
$ cargo run foo.fe 
    Blocking waiting for file lock on build directory
   Compiling fe-library v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/library)
   Compiling fe-test-files v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/test-files)
   Compiling fe-common v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/common)
   Compiling fe-parser v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/parser)
   Compiling fe-analyzer v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/analyzer)
   Compiling fe-abi v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/abi)
   Compiling fe-lowering v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/lowering)
   Compiling fe-yulgen v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/yulgen)
   Compiling fe-driver v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/driver)
   Compiling fe-yulc v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/yulc)
   Compiling fe-compiler-test-utils v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/test-utils)
   Compiling fe v0.12.0-alpha (/home/cburgdorf/Documents/hacking/ef/fe/crates/fe)
    Finished dev [unoptimized] target(s) in 59.39s
     Running `target/debug/fe foo.fe`
Warning: bytecode output requires 'solc-backend' feature. Try `cargo build --release --features solc-backend`. Skipping.
Unable to compile foo.fe.
error: missing colon in contract definition
  ┌─ foo.fe:1:11
  │
1 │ contract o
  │           ^ expected `:` here

error: failed to parse field definition
  ┌─ foo.fe:2:10
  │
2 │  pub def r(z:u256)
  │          ^ expected symbol `:`, found a name
  │
  = Hint: use `fn` to define a function
  = Example: `pub fn r( ...`
  = Note: field name must be followed by a colon and a type description
  = Example: pub def: address

But I can confirm the second one with the empty list expression. Looking into it.

agroce commented 2 years ago

Try this instead:

use
Warning: bytecode output requires 'solc-backend' feature. Try `cargo build --release --features solc-backend`. Skipping.
thread 'main' panicked at 'internal error: entered unreachable code', crates/parser/src/lexer/token.rs:304:22
stack backtrace:
   0:     0x563a4ba6967c - std::backtrace_rs::backtrace::libunwind::trace::hf6a6dfd7da937cb0
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x563a4ba6967c - std::backtrace_rs::backtrace::trace_unsynchronized::hc596a19e4891f7f3
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x563a4ba6967c - std::sys_common::backtrace::_print_fmt::hb16700db31584325
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x563a4ba6967c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h231c4190cfa75162
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x563a4ba86acc - core::fmt::write::h2a1462b5f8eea807
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/fmt/mod.rs:1163:17
   5:     0x563a4ba66245 - std::io::Write::write_fmt::h71ddfebc68685972
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/io/mod.rs:1696:15
   6:     0x563a4ba6b0e0 - std::sys_common::backtrace::_print::hcc197d4bebf2b369
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x563a4ba6b0e0 - std::sys_common::backtrace::print::h335a66af06738c7c
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x563a4ba6b0e0 - std::panicking::default_hook::{{closure}}::h6fac9ac9c8b79e52
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:210:50
   9:     0x563a4ba6ac95 - std::panicking::default_hook::h341c1030c6a1161b
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:227:9
  10:     0x563a4b9bbddf - fe_common::panic::report_ice::h3873cf98d32e7b02

You've hit an internal compiler error. This is a bug in the Fe compiler.
Fe is still under heavy development, and isn't yet ready for production use.

If you would, please report this bug at the following URL:
  https://github.com/ethereum/fe/issues/new
Aborted
agroce commented 2 years ago

Hmm, no, the copy doesn't repro. You need to create it like this:

> python
>>> with open ("k.fe", "wb") as f:
>>>    f.write('use\x07')
agroce commented 2 years ago

probably an unprinting char missing in that first one too, but it found this simpler version it prefers in triage rules

cburgdorf commented 2 years ago

Thanks, I'll look into that, too. I already opened a PR for the empty list expression crash and added a test to ensure we won't regress again.

https://github.com/ethereum/fe/pull/625