Thread 'main' panicked at 'assertion failed: index < len', src/liballoc/vec.rs:

I'm trying to run an app developed with actix-web and rustls but I get panic:

thread 'main' panicked at 'assertion failed: index < len', src/liballoc/vec.rs:9

maybe I created the cert wrong:

openssl genrsa 2048 &gt; key.pem

openssl req -x509 -days 1000 -new -key key.pem -out cert.pem

This is my main.rs file

I think maybe the issue is regarding with rustls.

Libraries aren't supposed to panic on out-of-bounds vec access, so that's a bug in one of them.

Try enabling full backtrace and see which library panics, and file an issue.

1 Like

Hello @kornel, thanks for you answer. Enabling backtrace I get this:

   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:385
   6: rust_begin_unwind
             at src/libstd/panicking.rs:312
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   8: core::panicking::panic
             at src/libcore/panicking.rs:49
   9: gloria_kwok_api::main
  10: std::rt::lang_start::{{closure}}
  11: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:297
  12: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  13: std::rt::lang_start_internal
             at src/libstd/panicking.rs:276
             at src/libstd/panic.rs:388
             at src/libstd/rt.rs:48
  14: main
  15: __libc_start_main
  16: _start

also I will debug the app to figure out where exactly break

let mut keys = rsa_private_keys(key_file).unwrap();
config.set_single_cert(cert_chain, keys.remove(0)).unwrap();
graphql_config.set_single_cert(cert_chain_graphql, keys.remove(0)).unwrap();

Are config and graphql_config supposed to receive different keys or the same key?

2 Likes

I fixed the problem. It is because both were reading from the same buffer. Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.