Skip to content

Commit

Permalink
jemalloc-sys: hardening strerror_r function detection
Browse files Browse the repository at this point in the history
test on strerror_r can fail due to reasons other than strerror_r
itself, so add an additional test to determine the failure is
expected.

Also remove stale arch condition.

Close #108.

Signed-off-by: Jay Lee <[email protected]>
  • Loading branch information
BusyJay committed Feb 8, 2025
1 parent 8c926d5 commit 143c253
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
3 changes: 0 additions & 3 deletions jemalloc-ctl/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ macro_rules! r {

#[cfg(test)]
#[test]
#[cfg(not(target_arch = "mips64el"))]
#[allow(unused)]
fn [<$id _read_test>]() {
match stringify!($id) {
Expand Down Expand Up @@ -112,7 +111,6 @@ macro_rules! w {

#[cfg(test)]
#[test]
#[cfg(not(target_arch = "mips64el"))]
fn [<$id _write_test>]() {
match stringify!($id) {
"background_thread" |
Expand Down Expand Up @@ -161,7 +159,6 @@ macro_rules! u {

#[cfg(test)]
#[test]
#[cfg(not(target_arch = "mips64el"))]
#[allow(unused)]
fn [<$id _update_test>]() {
match stringify!($id) {
Expand Down
1 change: 0 additions & 1 deletion jemalloc-ctl/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ union MaybeUninit<T: Copy> {
mod tests {
use super::*;
#[test]
#[cfg(not(target_arch = "mips64el"))] // FIXME: SIGFPE
fn test_ptr2str() {
unsafe {
//{ // This is undefined behavior:
Expand Down
37 changes: 37 additions & 0 deletions jemalloc-sys/configure/configure
Original file line number Diff line number Diff line change
Expand Up @@ -14143,6 +14143,41 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_strerror_r_returns_char_with_gnu_source" >&5
$as_echo "$je_cv_strerror_r_returns_char_with_gnu_source" >&6; }

if test "x${je_cv_strerror_r_returns_char_with_gnu_source}" = "xno" ; then

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror_r header only is compilable" >&5
$as_echo_n "checking whether strerror_r header only is compilable... " >&6; }
if ${je_cv_strerror_r_header_pass+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
je_cv_strerror_r_header_pass=yes
else
je_cv_strerror_r_header_pass=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_strerror_r_header_pass" >&5
$as_echo "$je_cv_strerror_r_header_pass" >&6; }

fi
CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}"
if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then
CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}"
Expand All @@ -14155,6 +14190,8 @@ if test "x${je_cv_strerror_r_returns_char_with_gnu_source}" = "xyes" ; then

$as_echo "#define JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE " >>confdefs.h

elif test "x${je_cv_strerror_r_header_pass}" = "xno" ; then
as_fn_error $? "cannot determine return type of strerror_r" "$LINENO" 5
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
Expand Down
2 changes: 1 addition & 1 deletion jemalloc-sys/jemalloc
Submodule jemalloc updated 1 files
+29 −4 configure.ac

0 comments on commit 143c253

Please sign in to comment.