Skip to content

Commit

Permalink
Abort on bad unlock and safe core dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Jul 26, 2017
1 parent fbc2c08 commit 82b1a12
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion openssl-sys/src/ossl10x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down Expand Up @@ -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();
}
}
}

Expand Down

0 comments on commit 82b1a12

Please sign in to comment.