Skip to content

Segmentation fault if blosc2 is updated to version 2.15.2 #21

@musicinmybrain

Description

@musicinmybrain

I first observed this with the patched rust-blosc2-sys in Fedora Rawhide (or Fedora 41), which always uses the system C blosc2 library and always re-generates bindings; it appeared as a regression when Fedora’s blosc2 package was updated from 2.15.1 to 2.15.2. However, with some effort, I was able to reproduce it in a git checkout without anything Fedora-specific

First, get a branch of blosc2-rs/blosc2-sys with an updated C library, as in milesgranger/blosc2-rs#33:

$ git checkout https://github.com/milesgranger/blosc2-rs.git
$ cd blosc2-rs
$ git remote add musicinmybrain git@github.com:musicinmybrain/blosc2-rs.git
$ git fetch --all
$ git checkout c-blosc2-2.15.2
$ git submodule update --init --recursive
$ cargo test --workspace
(everything passes)

Now, build libcramjam with that:

$ cd ..
$ git checkout https://github.com/cramjam/libcramjam.git
$ cd libcramjam
$ vim Cargo.toml
diff --git a/Cargo.toml b/Cargo.toml
index e1c129d..4dbd7b0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -64,7 +64,7 @@ lz4            = { version = "^1", optional = true }
 flate2         = { version = "^1", optional = true }
 libdeflater    = { version = "^1", optional = true }
 libdeflate-sys = { version = "<1.20.0", optional = true }  # TODO: requires gcc>=4.9 not available on Python's CI wheel builds
-blosc2-rs      = { version = "0.3.1+2.15.1", optional = true, default-features = false }
+blosc2-rs      = { path = "../blosc2-rs", optional = true, default-features = false }
 zstd           = { version = "^0.13", optional = true }
 xz2            = { version = "0.1.7", optional = true }
 
$ cargo test --workspace
     Locking 2 packages to latest compatible versions
      Adding blosc2-rs v0.3.1+2.15.2 (/home/ben/src/forks/blosc2-rs)
      Adding blosc2-sys v0.3.1+2.15.2 (/home/ben/src/forks/blosc2-rs/blosc2-sys)
   Compiling libcramjam v0.6.0 (/home/ben/src/forks/libcramjam)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.87s
     Running unittests src/lib.rs (target/debug/deps/libcramjam-a1c845d8657054f6)

running 57 tests
test lz4::block::tests::round_trip_store_size ... ok
test lz4::block::tests::round_trip_no_store_size ... ok
test blosc2::tests::test_compress ... ok
test igzip::tests::test_gzip_multiple_streams ... ok
test gzip::tests::test_gzip_multiple_streams ... ok
error: test failed, to rerun pass `--lib`

Caused by:
  process didn't exit successfully: `/home/ben/src/forks/libcramjam/target/debug/deps/libcramjam-a1c845d8657054f6` (signal: 11, SIGSEGV: invalid memory reference)
$ rust-gdb /home/ben/src/forks/libcramjam/target/debug/deps/libcramjam-a1c845d8657054f6
(gdb) run
running 57 tests
[New Thread 0x7ffff7c696c0 (LWP 3180234)]
[New Thread 0x7ffff7a686c0 (LWP 3180235)]
[New Thread 0x7ffff78676c0 (LWP 3180236)]
[New Thread 0x7ffff76666c0 (LWP 3180237)]
[New Thread 0x7ffff6e656c0 (LWP 3180238)]
[New Thread 0x7ffff6c3b6c0 (LWP 3180239)]
[New Thread 0x7ffff643a6c0 (LWP 3180240)]
[Thread 0x7ffff6e656c0 (LWP 3180238) exited]
[New Thread 0x7ffff62396c0 (LWP 3180241)]
[Thread 0x7ffff643a6c0 (LWP 3180240) exited]
[New Thread 0x7ffff5a386c0 (LWP 3180242)]
[New Thread 0x7ffff57e16c0 (LWP 3180243)]
[Thread 0x7ffff7a686c0 (LWP 3180235) exited]
[New Thread 0x7ffff4fe06c0 (LWP 3180244)]
[Thread 0x7ffff57e16c0 (LWP 3180243) exited]
[Thread 0x7ffff62396c0 (LWP 3180241) exited]
[Thread 0x7ffff6c3b6c0 (LWP 3180239) exited]
[Thread 0x7ffff76666c0 (LWP 3180237) exited]
[Thread 0x7ffff78676c0 (LWP 3180236) exited]
[Thread 0x7ffff7c696c0 (LWP 3180234) exited]
[New Thread 0x7ffff57e16c0 (LWP 3180245)]
[New Thread 0x7ffff62396c0 (LWP 3180246)]
[New Thread 0x7ffff6c3b6c0 (LWP 3180247)]
[New Thread 0x7ffff76666c0 (LWP 3180248)]
[New Thread 0x7ffff4d436c0 (LWP 3180249)]
[New Thread 0x7ffff4b426c0 (LWP 3180250)]
[New Thread 0x7ffff48b96c0 (LWP 3180251)]
[New Thread 0x7ffff46b86c0 (LWP 3180252)]
[New Thread 0x7ffff43806c0 (LWP 3180253)]
test lz4::block::tests::round_trip_no_store_size ... ok
[New Thread 0x7ffff6e656c0 (LWP 3180254)]
test lz4::block::tests::round_trip_store_size ... ok
[New Thread 0x7ffff643a6c0 (LWP 3180255)]
test gzip::tests::test_gzip_multiple_streams ... ok
[New Thread 0x7ffff7a686c0 (LWP 3180256)]
test igzip::tests::test_gzip_multiple_streams ... ok
[New Thread 0x7ffff78676c0 (LWP 3180257)]
test blosc2::tests::test_compress ... ok
[New Thread 0x7ffff7c696c0 (LWP 3180258)]

Thread 12 "tests::blosc2::" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff4fe06c0 (LWP 3180244)]
0x00005555559eefda in blosc2::schunk::SChunk::typesize (self=0x7ffff4fdebd8) at src/lib.rs:1038
1038                self.inner().typesize as _

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions