aleaxit / gmpy

General Multi-Precision arithmetic for Python 2.6+/3+ (GMP, MPIR, MPFR, MPC)
https://gmpy2.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
522 stars 86 forks source link

Add signal handler to catch SIGFPE on the GMP 6.3+ #513

Closed skirpichev closed 2 months ago

skirpichev commented 2 months ago

Since 6.3.0 some memory errors in mpz/realloc.c trigger SIGFPE exception. I think it's an upstream bug: helpful message should be emitted instead.

This patch install SIGFPE handler, that does this.

Closes #497

codecov-commenter commented 2 months ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 85.59%. Comparing base (224745b) to head (dfaae94). Report is 46 commits behind head on master.

Files with missing lines Patch % Lines
src/gmpy2.c 25.00% 3 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #513 +/- ## ========================================== + Coverage 85.52% 85.59% +0.06% ========================================== Files 50 50 Lines 11656 11660 +4 Branches 2202 2202 ========================================== + Hits 9969 9980 +11 + Misses 1687 1680 -7 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

skirpichev commented 2 months ago

GMP_ERROR_DIVISION_BY_ZERO and GMP_ERROR_SQRT_OF_NEGATIVE, in principle, shouldn't be triggered by some code in the gmpy2 codebase. Maybe I should check only GMP_ERROR_MPZ_OVERFLOW?

casevh commented 2 months ago

GMP_ERROR_DIVISION_BY_ZERO and GMP_ERROR_SQRT_OF_NEGATIVE, in principle, shouldn't be triggered by some code in the gmpy2 codebase. Maybe I should check only GMP_ERROR_MPZ_OVERFLOW?

While GMP_ERROR_DIVISION_BY_ZERO and GMP_ERROR_SQRT_OF_NEGATIVE shouldn't occur, I think it's fine to catch all the errors.