-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC:Removal of gmp_wrapper.c #2222
Conversation
LGTM |
This causes a segfault in |
Is there a way to figure out the string length adaptively - doubling the allocation every time it fails until it is successful? |
For larger numbers, it takes order of 10 secs to convert to strings. Doing it adaptively is going to hugely increase the time. There are gmp functions to write out the string to a file handle. That may be an option. http://gmplib.org/manual/I_002fO-of-Integers.html#I_002fO-of-Integers |
@aviks Thank you for the example. It is a very big number. I think that |
Maybe we should move the bigfib example into the tests? |
It works. I can add the bigfib to the tests as part of this request. |
The example takes around 20 seconds, which might get annoying if you are trying to run the tests often (as you should :) ) |
That's a fair point. Perhaps we need a somewhat smaller version of the test? |
I think it works now. The Fibonacci example runs and is included as test in a smaller version. The conversions to strings now use functions that are not warned against in the documentation. In order to get the the float conversion to work, I have changed to scientific notation and changed the tests accordingly. Is that okay? |
Looks good to me. |
@JeffBezanson Thank you for the comments. I have updated the code. |
@andreasnoackjensen If you are ready with this one, please feel free to merge. |
While the test works for me if I run it with |
Ok - this was perhaps some transient stuff, since a couple of updates and rebuilding of sys.ji, it works fine for me. |
I cannot provoke it locally but Travis seem to segfault irregularly on the bigint test. Do you think it is a Travis thing or a BigInt thing? |
Valgrind says:
This only happens for a sufficiently large |
We should perhaps plan revert this one today, given that we have a pretty tight window, and we need the build to be in good condition. @andreasnoackjensen Do you want to see if you can chase this one down or revert it today? This could live on a branch until it is figured out. |
I'll look into it and see if can get that string conversion right (or revert). |
The build is consistently passing. |
Does b92272a fix the problem? |
I get the same valgrind output. It only happens the first time I do |
The segfault disappears if the string is assigned before return (I have added the zero again). Please have a look at af3e11d. Any ideas? I cannot get the segfault locally and hence not use valgrind. |
If this fixes the issue, it would be worth to pull this in before tagging 0.1. @JeffBezanson should probably try it out with valgrind again. Also a heads up to @StefanKarpinski |
Huh? |
Since you are going to tag, this issue needs to be resolved - either the suggestion fixes things and is merged, or we need to bring back gmp_wrapper.c again. Doing neither of these and leaving things as they are is probably not a good thing. |
I actually don't know whether the valgrind error is relevant; I've never seen the segfault on my system. |
I have never seen the segfault too - but it could happen on debian's build systems if it happened on travis. Hopefully, we should find out quickly if that happens, and do something about it. |
Inspired by librandom.jl I have tried to rewrite the gmp interface to avoid gmp_wrapper.c. I can't make it not work on OS X, Ubuntu 32 and 64 bit, but maybe I have missed some memory issues somewhere. I have introduced a limit to the size of the string that can be returned, but it should be easy to change.
See also: #1887 and #2190