From a16ebb0dcb902a696d7c9a5432cce7482b9ce886 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 23 Jun 2017 11:52:22 -0700 Subject: [PATCH] Use `nm` to weed out panics --- ci/run.sh | 13 ++++++++++++- src/float/conv.rs | 2 ++ src/int/mul.rs | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index e5c8924..3316a43 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -63,7 +63,6 @@ case $1 in ;; esac -# Look out for duplicated symbols when we include the compiler-rt (C) implementation PREFIX=$(echo $1 | sed -e 's/unknown-//')- case $1 in armv7-*) @@ -95,6 +94,7 @@ else path=/target/${1}/debug/deps/libcompiler_builtins-*.rlib fi +# Look out for duplicated symbols when we include the compiler-rt (C) implementation for rlib in $(echo $path); do set +x stdout=$($PREFIX$NM -g --defined-only $rlib 2>&1) @@ -109,4 +109,15 @@ for rlib in $(echo $path); do set -ex done +# Ensure no references to a panicking function +for rlib in $(echo $path); do + set +x + $PREFIX$NM -u $rlib 2>&1 | grep panicking + + if test $? = 0; then + exit 1 + fi + set -ex +done + true diff --git a/src/float/conv.rs b/src/float/conv.rs index edf9ee6..053c681 100644 --- a/src/float/conv.rs +++ b/src/float/conv.rs @@ -78,6 +78,7 @@ intrinsics! { int_to_float!(i, i32, f64) } + #[use_c_shim_if(any(target_arch = "x86", target_arch = "x86_64"))] pub extern "C" fn __floatdidf(i: i64) -> f64 { int_to_float!(i, i64, f64) } @@ -100,6 +101,7 @@ intrinsics! { int_to_float!(i, u32, f64) } + #[use_c_shim_if(any(target_arch = "x86", target_arch = "x86_64"))] pub extern "C" fn __floatundidf(i: u64) -> f64 { int_to_float!(i, u64, f64) } diff --git a/src/int/mul.rs b/src/int/mul.rs index cb3fbd6..9241ee6 100644 --- a/src/int/mul.rs +++ b/src/int/mul.rs @@ -54,11 +54,11 @@ trait Mulo: Int + ops::Neg { return result; } if sa == sb { - if abs_a > Self::max_value() / abs_b { + if abs_a > Self::max_value().checked_div(abs_b).unwrap_or_else(|| ::abort()) { *overflow = 1; } } else { - if abs_a > Self::min_value() / -abs_b { + if abs_a > Self::min_value().checked_div(-abs_b).unwrap_or_else(|| ::abort()) { *overflow = 1; } }