qryxip / cargo-equip

A Cargo subcommand to bundle your code into one `.rs` file for competitive programming
Apache License 2.0
76 stars 10 forks source link

segmentation fault: cargo equip --exclude-atcoder-crates --resolve-cfgs --remove docs --minify #189

Closed kazuki-hanai closed 11 months ago

kazuki-hanai commented 1 year ago

I got segmentation fault error.

Result

❯ cargo equip --exclude-atcoder-crates --resolve-cfgs --remove docs --minify libs --rustfmt --check --bin pastbook2022-g
warning: `--resolve-cfgs` is deprecated. `#[cfg(..)]`s are resolved by default
warning: `--rustfmt` is deprecated. the output is formatted by default
warning: `--check` is deprecated. the output is checked by default
     Running `/Users/xxxx/.cargo/bin/rustup run nightly cargo udeps --output json -p pastbook2022 --bin pastbook2022-g`
    Checking pastbook2022 v0.1.0 (/Users/xxxx/xxxx/xxxxxxxx/pastbook2022)
warning: variable `N` should have a snake case name
 --> src/bin/g.rs:6:9
  |
6 |         N: usize,
  |         ^ help: convert the identifier to snake case: `n`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: variable `Q` should have a snake case name
 --> src/bin/g.rs:7:9
  |
7 |         Q: usize,
  |         ^ help: convert the identifier to snake case: `q`

warning: variable `A` should have a snake case name
 --> src/bin/g.rs:8:9
  |
8 |         A: [u64; N],
  |         ^ help: convert the identifier to snake case: `a`

warning: variable `TXY` should have a snake case name
 --> src/bin/g.rs:9:9
  |
9 |         TXY: [(usize, usize, u64); Q],
  |         ^^^ help: convert the identifier to snake case: `txy`

warning: `pastbook2022` (bin "pastbook2022-g") generated 4 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.55s
info: Loading depinfo from "/Users/xxxx/target/debug/deps/pastbook2022_g-aae5a6c66b940542.d"
    Bundling the code
zsh: segmentation fault  cargo equip --exclude-atcoder-crates --resolve-cfgs --remove docs --minify   

Source code

fn main() { input!{ N: usize, Q: usize, A: [u64; N], TXY: [(usize, usize, u64); Q], }

let mut segtree = segtree::Segtree::<segtree::Min<u64>>::new(N);
for i in 0..A.len() {
    segtree.set(i, A[i]);
}

let mut anss = vec!{};
for (t, x, y) in TXY {
    if t == 1 {
        segtree.set(x, y);
    } else if t == 2 {
        let minval = segtree.prod(x as usize..y as usize);
        anss.push(minval);
    }
}

for ans in anss {
    println!("{}", ans);
}

}


- Cargo.toml

[package] name = "pastbook2022" version = "0.1.0" edition = "2018"

[package.metadata.cargo-compete.bin] pastbook2022-a = { alias = "a", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_a" } pastbook2022-b = { alias = "b", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_b" } pastbook2022-c = { alias = "c", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_c" } pastbook2022-d = { alias = "d", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_d" } pastbook2022-e = { alias = "e", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_e" } pastbook2022-f = { alias = "f", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_f" } pastbook2022-g = { alias = "g", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_g" } pastbook2022-h = { alias = "h", problem = "https://atcoder.jp/contests/pastbook2022/tasks/pastbook2022_h" }

[[bin]] name = "pastbook2022-a" path = "src/bin/a.rs"

[[bin]] name = "pastbook2022-b" path = "src/bin/b.rs"

[[bin]] name = "pastbook2022-c" path = "src/bin/c.rs"

[[bin]] name = "pastbook2022-d" path = "src/bin/d.rs"

[[bin]] name = "pastbook2022-e" path = "src/bin/e.rs"

[[bin]] name = "pastbook2022-f" path = "src/bin/f.rs"

[[bin]] name = "pastbook2022-g" path = "src/bin/g.rs"

[[bin]] name = "pastbook2022-h" path = "src/bin/h.rs"

[dependencies] num = "=0.2.1" num-bigint = "=0.2.6" num-complex = "=0.2.4" num-integer = "=0.1.42" num-iter = "=0.1.40" num-rational = "=0.2.4" num-traits = "=0.2.11" num-derive = "=0.3.0" ndarray = "=0.13.0" nalgebra = "=0.20.0" alga = "=0.9.3" libm = "=0.2.1" rand = { version = "=0.7.3", features = ["small_rng"] } getrandom = "=0.1.14" rand_chacha = "=0.2.2" rand_core = "=0.5.1" rand_hc = "=0.2.0" rand_pcg = "=0.2.1" rand_distr = "=0.2.2" petgraph = "=0.5.0" indexmap = "=1.3.2" regex = "=1.3.6" lazy_static = "=1.4.0" ordered-float = "=1.0.2" ascii = "=1.0.0" permutohedron = "=0.2.4" superslice = "=1.0.0" itertools = "=0.9.0" itertools-num = "=0.1.3" maplit = "=1.0.2" either = "=1.5.3" im-rc = "=14.3.0" fixedbitset = "=0.2.0" bitset-fixed = "=0.1.0" proconio = { version = "=0.3.6", features = ["derive"] } text_io = "=0.1.8" whiteread = "=0.5.0" rustc-hash = "=1.1.0" smallvec = "=1.2.0" ac-library-rs = { git = "https://github.com/rust-lang-ja/ac-library-rs" }

[dev-dependencies]


### Environment
```bash
❯ rustup show                                                                                                           
Default host: aarch64-apple-darwin
rustup home:  /Users/xxxx/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin (default)
stable-x86_64-apple-darwin
beta-aarch64-apple-darwin
nightly-aarch64-apple-darwin
1.68.2-aarch64-apple-darwin

active toolchain
----------------

stable-aarch64-apple-darwin (default)
rustc 1.68.2 (9eb3afe9e 2023-03-27)
❯ cargo equip -V
cargo-equip 0.19.0  
mizar commented 1 year ago

related: https://github.com/qryxip/cargo-compete/pull/200

https://github.com/qryxip/cargo-equip/blob/57a4bb66eb424d76f61c7f98df16306fceb587fd/Cargo.toml#L28

prettytable-rs 0.8.0 will cause segfault at latest (1.67.x or later) rust.

workaround:

rustup install 1.66.1
cargo +1.66.1 install cargo-compete --locked --force
cargo +1.66.1 install cargo-equip --locked --force
qryxip commented 11 months ago

Probably resolved by #193.

I will release next version tomorrow.

qryxip commented 11 months ago

Released v0.20.0.