Skip to content

Accessing field .offset inside test crashes test harness if incorrect #108087

Open
@dns2utf8

Description

@dns2utf8

While writing this bug report I realised a bug in my code that I never wrote to the file.
After I fixed that the tests summaries start to show up, but the details (stdout per failed test) are still missing.

Am I not allowed to call a symbol offset?

I tried this code:

pub struct ActiveFile {
    /// Clonable needed for metadata
    pub(crate) id: FileTag,
    /// The actual data buffer
    data: Vec<u8>,
    /// seekable
    offset: usize,
    /// Locked file
    real_file: File,
}

impl Drop for ActiveFile { ... }
impl Write for ActiveFile { ... }

#[cfg(test)]
mod tests {
    use super::*;
    use ring::aead::{BoundKey, UnboundKey};
    use std::path::PathBuf;
    
    #[test]
    fn simple_write() {
        let mut key = test_key();
        let mut a = ActiveFile::open_rwlocked(&path("simple_write.bin"), FileTag(1), &mut key)
            .expect("unable to open test file");

        a.write(b"abc").unwrap();
        println!("a.data: {:?}", a.data);
        assert_eq!(3, a.data.len());
    }

I expected to see this happen: explanation

Instead, this happened:
The code compiles starts running and crashes without printing the test cases (passed or failed).
The only way to get them to work is by removing assert_eq!(3, a.offset); from the test

(signal: 6, SIGABRT: process abort signal)

Meta

rustc --version --verbose, tried it with nightly too -> same result:

rustc 1.67.1 (d5a82bbd2 2023-02-07)
binary: rustc
commit-hash: d5a82bbd26e1ad8b7401f6a718a9c57c96905483
commit-date: 2023-02-07
host: x86_64-unknown-linux-gnu
release: 1.67.1
LLVM version: 15.0.6

There is no backtrace, just the short message

running 1 test
thread panicked while panicking. aborting.
error: test failed, to rerun pass `-p aead_vfs --lib`

Caused by:
  process didn't exit successfully: `$HOME/rust/encrypted_filesystem_storage/target/debug/deps/aead_vfs-dbf5b5fd9b41c8b0 secure_file` (signal: 6, SIGABRT: process abort signal)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-libtestArea: `#[test]` / the `test` libraryC-bugCategory: This is a bug.S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions