-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workaround for GMP crash on Cygwin (regression introduced by PR #3434) #3435
Conversation
…memory is really committed by the OS for a new bag. Call ENSURE_BAG on new bags created in integer.c if they might be passed as an argument to a GMP function.
(Rebased on current master branch; mine was quite a bit behind it seems.) |
Thanks. I like this PR. While we might be able to make it more efficient (by only touching each page), I'd like to keep it simple, as Cygwin is already poorly tested, and this is a very subtle issue. Once it is fixed in GMP, we might want to think about how to selectively enable it, or require the up to date version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I have some minor change requests. But overall, this seems very sensible to me.
This is actually what I tried first, but as you previously suspected it was trickier than I had expected to get the compiler to not just optimize it away. E.g. volatile had basically not effect with a local variable. I'm sure it can be done but I didn't want to spend a lot of time messing with it. |
Well, so far at least one of the GMP developers has been supportive of the idea: https://gmplib.org/list-archives/gmp-bugs/2019-May/004544.html GMP has some good version macros so it would be easy to disable based on a version check if/when fixed. I should probably look into how to check if GMP is actually MPIR, because MPIR actually doesn't have this problem as far as I can tell. In MPIR they rewrote everything to use the YASM assembler, which has implicit support for adding the stack unwinding metadata on Windows. |
…e only known use case.
Editorial note: Since this is a fix for a recent regression that was in no GAP release, there is no need for release notes. |
Codecov Report
@@ Coverage Diff @@
## master #3435 +/- ##
==========================================
- Coverage 80.2% 77.47% -2.73%
==========================================
Files 695 692 -3
Lines 342574 340498 -2076
==========================================
- Hits 274750 263810 -10940
- Misses 67824 76688 +8864
|
That said, would there be any objection to backporting this and #3335 to the 4.10-stable branch? If so for some reason that's fine. I just wondered. |
@embray at this point, I am not sure there will be any further release in the 4.10 line; we plan to release GAP 4.11 in May. |
Ah, ok. Fair enough. |
Thanks again for tracking this down. |
@ChrisJefferson @fingolfin could this be backported in GAP 4.10 |
Description
Adds
ENSURE_BAG
which on the relevant platform (Cygwin 64-bit, at least) simply zero-fills the contents of a bag before using it.This is perhaps a naive attempt and I'm not sure it covers every possible case, but it does at least fix the test case from #3434 using
Bernoulli()
.Needs proper documentation, but I'll add that if/when this approach is approved.
Text for release notes
Fixed crash on 64-bit Cygwin that could occur in some integer operations.
Checklist for pull request reviewers
If your code contains kernel C code, run
clang-format
on it; thesimplest way is to use
git clang-format
, e.g. like this (don'tforget to commit the resulting changes):
usage of relevant labels
release notes: not needed
orrelease notes: to be added
bug
orenhancement
ornew feature
stable-4.X
add thebackport-to-4.X
labelbuild system
,documentation
,kernel
,library
,tests
runnable tests
adequate pull request title
well formulated text for release notes
relevant documentation updates
sensible comments in the code