Commit 82b1a12f authored by Steven Fackler's avatar Steven Fackler
Browse files

Abort on bad unlock and safe core dumps

parent fbc2c08e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ job: &JOB
      export OPENSSL_DIR=$HOME/openssl
      cargo run --manifest-path=systest/Cargo.toml --target $TARGET
  - run: |
      ulimit -c unlimited
      export OPENSSL_DIR=$HOME/openssl
      export PATH=$OPENSSL_DIR/bin:$PATH
      if [ "${NO_RUN}" = "1" ]; then
@@ -37,6 +38,14 @@ job: &JOB
        --target $TARGET \
        --all-features \
        $TEST_ARGS
  - run:
      command: |
        mkdir -p /tmp/core_dumps
        find . -name "core.*" -exec cp \{\} /tmp/core_dumps \;
        cp target/$TARGET/debug/openssl-* /tmp/core_dumps
      when: on_fail
  - store_artifacts:
      path: /tmp/core_dumps
  - save_cache:
      key: deps-1.19.0-{{ checksum "Cargo.lock" }}-{{ checksum "~/lib_key" }}
      paths:
+5 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ use std::sync::{Mutex, MutexGuard};
use std::sync::{Once, ONCE_INIT};
use std::mem;
use std::ptr;
use std::process;

use libc::{c_int, c_char, c_void, c_long, c_uchar, size_t, c_uint, c_ulong};
#[cfg(not(ossl101))]
@@ -746,7 +747,10 @@ unsafe extern "C" fn locking_function(mode: c_int, n: c_int, _file: *const c_cha
    if mode & ::CRYPTO_LOCK != 0 {
        (*GUARDS)[n as usize] = Some(mutex.lock().unwrap());
    } else {
        &(*GUARDS)[n as usize].take().expect("lock already unlocked");
        if let None = &(*GUARDS)[n as usize].take() {
            println!("lock {} already unlocked", n);
            process::abort();
        }
    }
}