Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

build failed - thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2 #34

Closed
avp90 opened this issue Aug 28, 2019 · 4 comments

Comments

@avp90
Copy link

avp90 commented Aug 28, 2019

Hi @tarcieri,

after solving #33 i got these output (same on centos-release-7-6.1810.2.el7.centos.x86_64 and macOS 10.14.6):

thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/slice/mod.rs:2681:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

with backtrace:

thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/slice/mod.rs:2681:10
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::continue_panic_fmt
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::panicking::panic_bounds_check
   7: cargo_rpm::rpmbuild::Rpmbuild::version
   8: cargo_rpm::rpmbuild::Rpmbuild::new
   9: cargo_rpm::builder::Builder::build
  10: <cargo_rpm::commands::build::BuildCmd as abscissa_core::runnable::Runnable>::run
  11: abscissa_core::application::Application::run
  12: abscissa_core::application::boot
  13: cargo_rpm::main
  14: std::rt::lang_start::{{closure}}
  15: std::panicking::try::do_call
  16: __rust_maybe_catch_panic
  17: std::rt::lang_start_internal
  18: main

rpmbuild --version output:
RPM-Version 4.14.2.1

sudo dtruss -f -t open cargo rpm build -v output:

    PID/THRD  SYSCALL(args)          = return
     Running cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
    Creating release archive: BE_ApiGateway2-0.1.0.tar.gz
thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/slice/mod.rs:2681:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
10096/0x81c8:  open("/dev/dtracehelper\0", 0x2, 0xFFFFFFFFEF392FB0)                                                                         = 3 0
10096/0x81c8:  open("/usr/share/terminfo/78/xterm-256color\0", 0x1000000, 0x1B6)                                                            = 3 0
10096/0x81c8:  open("/dev/urandom\0", 0x1000000, 0x1B6)                                                                                     = 4 0
10096/0x81c8:  open("/Users/AP/.rustup/settings.toml\0", 0x1000000, 0x1B6)                                                                  = 3 0
10096/0x81c8:  open("/synectic/GIT/syn6/BE_ApiGateway2/rust-toolchain\0", 0x1000000, 0x1B6)                                                 = -1 Err#2
10096/0x81c8:  open("/synectic/GIT/syn6/rust-toolchain\0", 0x1000000, 0x1B6)                                                                = -1 Err#2
10096/0x81c8:  open("/synectic/GIT/rust-toolchain\0", 0x1000000, 0x1B6)                                                                     = -1 Err#2
10096/0x81c8:  open("/synectic/rust-toolchain\0", 0x1000000, 0x1B6)                                                                         = -1 Err#2
10096/0x81c8:  open("/rust-toolchain\0", 0x1000000, 0x1B6)                                                                                  = -1 Err#2
10096/0x81f9:  open("/dev/dtracehelper\0", 0x2, 0xFFFFFFFFE8A7FE20)                                                                         = 3 0
10096/0x81f9:  open("/dev/urandom\0", 0x1000000, 0x1B6)                                                                                     = 3 0
10096/0x81f9:  open("/Users/AP/.gitconfig\0", 0x1000000, 0x0)                                                                               = 3 0
10096/0x81fa:  open("/dev/dtracehelper\0", 0x2, 0xFFFFFFFFE5D77E10)                                                                         = 3 0
10096/0x81fa:  open("/dev/urandom\0", 0x1000000, 0x1B6)                                                                                     = 3 0
10096/0x81fa:  open("/synectic/GIT/syn6/BE_ApiGateway2/Cargo.toml\0", 0x1000000, 0x1B6)                                                     = 3 0
10096/0x81fa:  open("/synectic/GIT/syn6/BE_ApiGateway2/target/release/rpmbuild/SOURCES/BE_ApiGateway2-0.1.0.tar.gz\0", 0x1000601, 0x1B6)    = 3 0
10096/0x81fa:  open("/synectic/GIT/syn6/BE_ApiGateway2/target/release/BE_ApiGateway2\0", 0x1000000, 0x1B6)                                  = 4 0
10096/0x81fa:  open("./.rpm/BE_ApiGateway2.spec\0", 0x1000000, 0x1B6)                                                                       = 3 0
10096/0x81fa:  open("/synectic/GIT/syn6/BE_ApiGateway2/target/release/rpmbuild/SPECS/BE_ApiGateway2.spec\0", 0x1000601, 0x1B6)              = 4 0
10096/0x81fa:  open("/dev/null\0", 0x1000000, 0x1B6)                                                                                        = 3 0
@tarcieri
Copy link
Contributor

tarcieri commented Aug 28, 2019

Well, that's almost certainly here:

https://github.com/RustRPM/cargo-rpm/blob/98ed3fec412600fafb67ba25c8914fdf76cf8d0e/src/rpmbuild.rs#L78-L79

...which seems somewhat poorly written. Mea culpa.

In interest of figuring out what's going on, what is the output of rpmbuild --version?

@avp90
Copy link
Author

avp90 commented Aug 28, 2019

Here is the rpmbuild --version output:
RPM-Version 4.14.2.1

It is between the outputs above ;)

@avp90
Copy link
Author

avp90 commented Aug 29, 2019

RPM-Version 4.14.2.1 would be splitted in ["RPM-Version", "4.14.2.1"]. So the index 2 does not exist.

I suggest to replace https://github.com/RustRPM/cargo-rpm/blob/98ed3fec412600fafb67ba25c8914fdf76cf8d0e/src/rpmbuild.rs#L70-L79 with something like this:

    let MIN_RPMBUILD_VERSION: i8 = 4;
    let parts: Vec<&str> = vers.split(&[' ', '.'][..])
        .into_iter()
        .filter(|part| part.parse::<i8>().is_ok())
        .collect();
    let vers_number = parts.join(".");

    if parts.len() < 1 || parts[0].parse::<i8>().unwrap() < MIN_RPMBUILD_VERSION {
        fail!(
            ErrorKind::Rpmbuild,
            "unexpected rpmbuild version string: {:?}",
            vers_number
        );
    } else {
        Ok(vers_number)
    }

Because https://github.com/RustRPM/cargo-rpm/blob/98ed3fec412600fafb67ba25c8914fdf76cf8d0e/src/rpmbuild.rs#L70 is incorrect e.g. on version 3.0.4 it would try to build, but the version is not supported.

@tony-iqlusion
Copy link
Member

cargo-rpm is unmaintained: #96

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants