Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertion failed: current_offset <= next_offset in building regex #412

Closed
avanhatt opened this issue Aug 10, 2021 · 3 comments
Closed

assertion failed: current_offset <= next_offset in building regex #412

avanhatt opened this issue Aug 10, 2021 · 3 comments
Assignees
Labels
[C] Bug This is a bug. Something isn't working.

Comments

@avanhatt
Copy link
Contributor

avanhatt commented Aug 10, 2021

RMC panics in codegen_struct_padding when building the regex crate, specifically, regex-syntax.

Steps:

git clone [email protected]:rust-lang/regex.git
cd regex
RUSTC=rmc-rustc RUSTFLAGS="-Z trim-diagnostic-paths=no -Z codegen-backend=gotoc --cfg=rmc" cargo +nightly build --target x86_64-unknown-linux-gnu -j 1 

Output:

   Compiling cfg-if v1.0.0
   Compiling regex-syntax v0.6.25 (/home/ubuntu/regex/regex-syntax)
thread 'rustc' panicked at 'assertion failed: current_offset <= next_offset', compiler/rustc_codegen_llvm/src/gotoc/typ.rs:427:9
stack backtrace:
   0: rust_begin_unwind
             at /home/ubuntu/rmc/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /home/ubuntu/rmc/library/core/src/panicking.rs:93:14
   2: core::panicking::panic
             at /home/ubuntu/rmc/library/core/src/panicking.rs:50:5
   3: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_struct_padding
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:427:9
   4: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_struct_fields
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:476:25
   5: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_variant_struct_fields
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:724:9
   6: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_enum_case_struct::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:959:13
   7: rustc_codegen_llvm::gotoc::metadata::GotocCtx::ensure_struct
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs:158:30
   8: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_enum_case_struct
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:958:9
   9: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_enum_cases_union::{{closure}}::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:935:25
  10: core::iter::adapters::map::map_fold::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/adapters/map.rs:84:28
  11: core::iter::adapters::map::map_fold::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/adapters/map.rs:84:21
  12: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold::enumerate::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/adapters/enumerate.rs:106:27
  13: core::iter::traits::iterator::Iterator::fold
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:2170:21
  14: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold
             at /home/ubuntu/rmc/library/core/src/iter/adapters/enumerate.rs:112:9
  15: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /home/ubuntu/rmc/library/core/src/iter/adapters/map.rs:124:9
  16: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /home/ubuntu/rmc/library/core/src/iter/adapters/map.rs:124:9
  17: core::iter::traits::iterator::Iterator::for_each
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:733:9
  18: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
             at /home/ubuntu/rmc/library/alloc/src/vec/spec_extend.rs:40:17
  19: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
             at /home/ubuntu/rmc/library/alloc/src/vec/spec_from_iter_nested.rs:56:9
  20: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
             at /home/ubuntu/rmc/library/alloc/src/vec/spec_from_iter.rs:33:9
  21: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /home/ubuntu/rmc/library/alloc/src/vec/mod.rs:2466:9
  22: core::iter::traits::iterator::Iterator::collect
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:1745:9
  23: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_enum_cases_union::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:930:13
  24: rustc_codegen_llvm::gotoc::metadata::GotocCtx::ensure_union
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs:177:30
  25: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_enum_cases_union
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:929:9
  26: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_enum::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:821:33
  27: rustc_codegen_llvm::gotoc::metadata::GotocCtx::ensure_struct
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs:158:30
  28: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_enum
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:786:9
  29: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_ty
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:315:21
  30: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_ty_ref
  31: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_ty
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:345:76
  32: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_struct_fields
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:481:75
  33: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_variant_struct_fields
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:724:9
  34: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_struct::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:707:13
  35: rustc_codegen_llvm::gotoc::metadata::GotocCtx::ensure_struct
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs:158:30
  36: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_struct
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:704:9
  37: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_ty
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:311:21
  38: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_struct_fields
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:481:75
  39: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_variant_struct_fields
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:724:9
  40: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_struct::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:707:13
  41: rustc_codegen_llvm::gotoc::metadata::GotocCtx::ensure_struct
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs:158:30
  42: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_struct
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:704:9
  43: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_ty
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:311:21
  44: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::fn_typ::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:1006:80
  45: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /home/ubuntu/rmc/library/core/src/ops/function.rs:269:13
  46: core::iter::traits::iterator::Iterator::find_map::check::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:2407:32
  47: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::try_fold::enumerate::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/adapters/enumerate.rs:85:27
  48: core::iter::traits::iterator::Iterator::try_fold
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:1994:21
  49: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::try_fold
             at /home/ubuntu/rmc/library/core/src/iter/adapters/enumerate.rs:91:9
  50: core::iter::traits::iterator::Iterator::find_map
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:2413:9
  51: <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next
             at /home/ubuntu/rmc/library/core/src/iter/adapters/filter_map.rs:61:9
  52: alloc::vec::Vec<T,A>::extend_desugared
             at /home/ubuntu/rmc/library/alloc/src/vec/mod.rs:2563:35
  53: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
             at /home/ubuntu/rmc/library/alloc/src/vec/spec_extend.rs:18:9
  54: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
             at /home/ubuntu/rmc/library/alloc/src/vec/spec_from_iter_nested.rs:37:9
  55: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
             at /home/ubuntu/rmc/library/alloc/src/vec/spec_from_iter.rs:33:9
  56: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /home/ubuntu/rmc/library/alloc/src/vec/mod.rs:2466:9
  57: core::iter::traits::iterator::Iterator::collect
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:1745:9
  58: rustc_codegen_llvm::gotoc::typ::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::fn_typ
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/typ.rs:984:42
  59: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::declare_function::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:351:17
  60: rustc_codegen_llvm::gotoc::metadata::GotocCtx::ensure
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs:216:23
  61: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::declare_function
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:347:9
  62: <rustc_codegen_llvm::gotoc::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:453:35
  63: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::call_with_panic_debug_info::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:103:13
  64: std::thread::local::LocalKey<T>::try_with
             at /home/ubuntu/rmc/library/std/src/thread/local.rs:399:16
  65: std::thread::local::LocalKey<T>::with
             at /home/ubuntu/rmc/library/std/src/thread/local.rs:375:9
  66: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::call_with_panic_debug_info
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:101:9
  67: <rustc_codegen_llvm::gotoc::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:452:25
  68: rustc_interface::passes::start_codegen::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:1056:9
  69: rustc_data_structures::profiling::VerboseTimingGuard::run
             at /home/ubuntu/rmc/compiler/rustc_data_structures/src/profiling.rs:611:9
  70: rustc_session::utils::<impl rustc_session::session::Session>::time
             at /home/ubuntu/rmc/compiler/rustc_session/src/utils.rs:16:9
  71: rustc_interface::passes::start_codegen
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:1055:19
  72: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:254:20
  73: rustc_interface::passes::QueryContext::enter::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:780:42
  74: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1784:50
  75: rustc_middle::ty::context::tls::set_tlv
             at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1768:9
  76: rustc_middle::ty::context::tls::enter_context
             at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1784:9
  77: rustc_interface::passes::QueryContext::enter
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:780:9
  78: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:245:13
  79: rustc_interface::queries::Query<T>::compute
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:38:28
  80: rustc_interface::queries::Queries::ongoing_codegen
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:243:9
  81: rustc_driver::run_compiler::{{closure}}::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_driver/src/lib.rs:407:13
  82: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:394:19
  83: rustc_driver::run_compiler::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_driver/src/lib.rs:312:22
  84: rustc_interface::interface::create_compiler_and_run::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:209:13
  85: rustc_span::with_source_map
             at /home/ubuntu/rmc/compiler/rustc_span/src/lib.rs:911:5
  86: rustc_interface::interface::create_compiler_and_run
             at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:203:5
  87: rustc_interface::interface::run_compiler::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:225:12
  88: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:157:13
  89: scoped_tls::ScopedKey<T>::set
             at /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
  90: rustc_span::create_session_globals_then
             at /home/ubuntu/rmc/compiler/rustc_span/src/lib.rs:105:5
  91: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:155:9
  92: rustc_interface::util::scoped_thread::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:130:24
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.56.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z trim-diagnostic-paths=no -Z codegen-backend=gotoc -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack

[RMC] current codegen item: declare_function: std::fmt::DebugList::<'a, 'b>::entries

RMC unexpectedly panicked during code generation.

If you are seeing this message, please file an issue here instead of on the Rust compiler: https://github.com/model-checking/rmc/issues/new?labels=bug&template=bug_report.md
error: could not compile `regex-syntax`
@avanhatt avanhatt added the [C] Bug This is a bug. Something isn't working. label Aug 10, 2021
@adpaco-aws
Copy link
Contributor

We are getting a similar error when attempting to codegen the rand crate. Details are in #111.

@zhassan-aws
Copy link
Contributor

Here's a minimal example that hits the same assertion:

enum E {
    Foo { a: u64, b: u16, },
    Bar,
}

fn main() {
    let e = E::Foo { a: 32, b: 100 };
}

@avanhatt
Copy link
Contributor Author

avanhatt commented Sep 3, 2021

with #468 and cargo build instead of cargo test, regex now builds successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Bug This is a bug. Something isn't working.
Projects
None yet
Development

No branches or pull requests

3 participants