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

Cargo test leading to "unsafe precondition(s) violated" #442

Open
ebioman opened this issue Oct 11, 2024 · 0 comments
Open

Cargo test leading to "unsafe precondition(s) violated" #442

ebioman opened this issue Oct 11, 2024 · 0 comments

Comments

@ebioman
Copy link

ebioman commented Oct 11, 2024

I recently updated to 1.81.0 and while the normal compilation and everything works still fine, the cargo test leads to an error which I dont manage to get around.

thread 'tests::cluster2tree_1' panicked at library/core/src/panicking.rs:221:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
stack backtrace:

....
 6: rust_htslib::bcf::header::HeaderView::samples
             at ..../.cargo/registry/src/index.crates.io-6f17d22bba15001f/rust-htslib-0.47.0/src/bcf/header.rs:287:22
....

line

I tried to clean everything, building in a different environment,... always hitting that wall now.

Update:

Versions:

  • rust stable 1.81.0
  • htslib 0.47.0

Interestingly, it really seems to relate only to debug builds as used in cargo test.
If I run cargo test --release everything succeeds.
If I compile my binary with debug vs release, the results are very different:

target/release/vcf_sv_cluster --vcf test/vcf_cluster/corner_case2.vcf  --chroms test/vcf_cluster/corner_case2.length
001165F	50852	50867	000084F	1239761	1239776	corner_case2:FID.792.2;	1	+	-	BND_PAIR

--> works as expected

target/debug/vcf_sv_cluster --vcf test/vcf_cluster/corner_case2.vcf  --chroms test/vcf_cluster/corner_case2.length
thread 'main' panicked at library/core/src/panicking.rs:221:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)

I dont know how this is possible at the moment

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

No branches or pull requests

1 participant