Path: blob/main/lang/ecl/files/patch-75877dd.c
16151 views
From 75877dd8f0d534552284ba4380ba65baa74f028f Mon Sep 17 00:00:00 20011From: Marius Gerbershagen2Date: Sun, 28 Jun 2020 11:02:15 +02003Subject: [PATCH] fpe: fix ECL_WITH_LISP_FPE macro45We can't use ecl_process_env_unsafe() == NULL to check if ECL has6booted because the return value of ecl_process_env_unsafe is7unpredictable before ECL has booted. The reason is that8ecl_process_env_unsafe calls pthread_getspecific with an uninitialized9key stored in cl_env_key. But another call to pthread_setspecific10might have already registered a key which happens to be the same as11the not yet initialized cl_env_key, yielding a non-NULL value.12---13src/h/impl/math_fenv.h | 17 ++++++++---------141 file changed, 8 insertions(+), 9 deletions(-)1516diff --git a/src/h/impl/math_fenv.h b/src/h/impl/math_fenv.h17index 0a93c8e0a..9630f4c6c 10064418--- src/h/impl/math_fenv.h19+++ src/h/impl/math_fenv.h20@@ -72,15 +72,14 @@2122#if defined(HAVE_FENV_H) && !defined(ECL_AVOID_FPE_H)23# if defined(HAVE_FEENABLEEXCEPT)24-# define ECL_WITH_LISP_FPE_BEGIN do { \25- fenv_t __fenv; \26- fegetenv(&__fenv); \27- cl_env_ptr __the_env = ecl_process_env_unsafe(); \28- if (__the_env) { \29- int bits = __the_env->trap_fpe_bits; \30- fedisableexcept(FE_ALL_EXCEPT & ~bits); \31- feenableexcept(FE_ALL_EXCEPT & bits); \32- } \33+# define ECL_WITH_LISP_FPE_BEGIN do { \34+ fenv_t __fenv; \35+ fegetenv(&__fenv); \36+ if (ecl_get_option(ECL_OPT_BOOTED) > 0) { \37+ int bits = ecl_process_env()->trap_fpe_bits; \38+ fedisableexcept(FE_ALL_EXCEPT & ~bits); \39+ feenableexcept(FE_ALL_EXCEPT & bits); \40+ } \41feclearexcept(FE_ALL_EXCEPT);42# else43# define ECL_WITH_LISP_FPE_BEGIN do { \44--45GitLab46474849