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

Random false failures in CI #1730

Open
bkstein opened this issue Nov 9, 2022 · 3 comments
Open

Random false failures in CI #1730

bkstein opened this issue Nov 9, 2022 · 3 comments

Comments

@bkstein
Copy link
Contributor

bkstein commented Nov 9, 2022

I have a test on my branch, which sometimes fails in CI and sometimes not, even if the code didn't change. See the last two actions:

The test never fails locally (that's why I can't debug it), so I assume, there is something unpredictable in the CI setup of this particular job (always windows-vcpkg). The test itself is simple and the error occurs before my new feature is called:

    #[test]
    fn asn1_string_from_asn1_type() {
        let null = null_mut();
        unsafe {
            // Create an ASN.1 type object
            let s = CString::new("PRINTABLESTRING:Hello Test").unwrap();
            cfg_if! {
                if #[cfg(any(ossl110, libressl280))] {
                    let s_ptr = s.as_ptr() as *const _;
                } else {
                    let s_ptr = s.as_ptr() as *mut _;
                }
            }
            let at: Asn1Type = cvt_p(ffi::ASN1_generate_v3(s_ptr, null))
                .map(|p| Asn1Type::from_ptr(p))
                .unwrap();
            assert_eq!(at.as_ref().typ(), Asn1TagValue::PRINTABLESTRING);
            // Get string content from Asn1Type
            let asn1stringref: &Asn1StringRef = Asn1StringRef::from_asn1type(at.as_ref()).unwrap();
            let osslstring: OpensslString = asn1stringref.as_utf8().unwrap();
            let string: &str = osslstring.as_ref();
            assert_eq!("Hello Test", string);
        }
    }

and it fails in OpenSSL which pretends not to know the tag PRINTABLESTRING:

---- asn1::tests::asn1_string_from_asn1_type stdout ----
thread 'asn1::tests::asn1_string_from_asn1_type' panicked at 'called `Result::unwrap()` on an `Err` value:
ErrorStack([
    Error { 
        code: 109052098,
        library: "asn1 encoding routines",
        function: "asn1_cb",
        reason: "unknown tag",
        file: "crypto\\asn1\\asn1_gen.c",
        line: 266,
        data: "tag=PRINTABLESTRING:Hello Test"
    },
    Error {
        code: 109052098,
        library: "asn1 encoding routines",
        function: "ASN1_generate_v3",
        reason: "unknown tag",
        file: "crypto\\asn1\\asn1_gen.c",
        line: 94
    }
])', openssl\src\asn1.rs:1068:18
...
failures:
    asn1::tests::asn1_string_from_asn1_type
@sfackler
Copy link
Owner

It seems like it is definitely a real failure to me. OpenSSL has previously had race conditions in its internal state initialization that could cause errors like this during concurrent calls.

@bkstein
Copy link
Contributor Author

bkstein commented Nov 10, 2022

A race condition, yes. That's possible. I was not aware of cargo test executing multiple threads by default. Should we restrict testing to a single thread?

$ cargo test -- --test-threads=1

@sfackler
Copy link
Owner

The general expectation is that these APIs should be thread safe. It seems inadvisable to test exclusively in a single threaded context.

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

2 participants