Skip to content

rebase: Throw OutOfMemoryError when gmp tries to allocate memory beyond the limit #31215

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

Merged
merged 2 commits into from
Mar 6, 2019

Conversation

musm
Copy link
Contributor

@musm musm commented Feb 28, 2019

rebased #29029
and closes #8286
courtesy @grep0

…imit.

Only works with patched GMP; does nothing if linked agaist system GMP.
@musm musm changed the title Masterd rebase: Throw OutOfMemoryError when gmp tries to allocate memory beyond the limit Feb 28, 2019
base/gmp.jl Outdated
A reference that holds a boolean, if true, indicating julia is linked with a patched GMP that
does not abort on huge allocation and throws OutOfMemoryError instead.
"""
const HAS_ALLOC_OVERFLOW_FUNCTION = Ref(false)
Copy link
Contributor Author

@musm musm Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this name fine? Uppercase and all? What about ALLOC_OVERFLOW_PATCH ?

@musm
Copy link
Contributor Author

musm commented Mar 1, 2019

I'm building julia but for some reason it's not picking up patches to GMP. My Make.user file looks like

MARCH=native
USE_BINARYBUILDER_LLVM=1
USE_BINARYBUILDER_OPENBLAS=1
USE_BINARYBUILDER_SUITESPARSE=1

Do I have to do anything special to make sure julia builds the patched GMP file?

FWIW this is from a cross-compile and withan out of tree build

Fixed: I had to delete the srcache file to get julia to patch the gmp file.

@musm
Copy link
Contributor Author

musm commented Mar 4, 2019

Alright this PR is ready to be merged when ready. I confirmed also that it works locally.

@musm
Copy link
Contributor Author

musm commented Mar 5, 2019

Looks like an unrelated spawn failure on 32-bit windows.

@KristofferC
Copy link
Member

Restarted it

@musm
Copy link
Contributor Author

musm commented Mar 5, 2019

thanks all green now

@musm
Copy link
Contributor Author

musm commented Mar 6, 2019

@JeffBezanson you approved the original PR, does this now look good to merge?

@KristofferC KristofferC merged commit 00d6750 into JuliaLang:master Mar 6, 2019
@musm musm deleted the masterd branch March 6, 2019 14:30
@doronbehar
Copy link

Hey all and sorry for bumping an old thread. I'm trying to collect what libraries that Julia depends upon, haven't included the patches you suggested them. I noticed that GMP 6.2.0, which was released long enough after this PR, hasn't included the patch here. See:

https://gmplib.org/repo/gmp-6.2/file/tip/memory.c#l39

Is my observation correct? I'm curios because I'm trying to package Julia for my distro and I want to know what libraries it should be safe enough to use our distro's versions vs your patched versions.

@nalimilan
Copy link
Member

Indeed #8286 was marked as upstream, but nothing happened AFAICT.

@doronbehar
Copy link

Is there a link to an upstream patch submission? No feedback at all from their side? I even consider nagging them myself (yea I know it's not easy since it's a mailing list and not a GitHub PR) but I need something to hold on, not to mention I'd need to check the patch applies to their current version...

@nalimilan
Copy link
Member

I mean that AFAICT nobody reported it upstream so far. Filing an issue with our patch it probably better than doing nothing, even if the patch may be slightly outdated.

@StefanKarpinski
Copy link
Member

Agree. If you wouldn't mind doing that, it would be greatly appreciated.

@cmcaine
Copy link
Contributor

cmcaine commented Oct 6, 2020

I emailed this to the gmp-bugs mailing list today because it didn't look like anyone else had done it yet.

If the mailing list software didn't hate gmail then it should be publicly visible in the October archives in a few days: https://gmplib.org/list-archives/gmp-bugs/2020-October/thread.html

@musm
Copy link
Contributor Author

musm commented Oct 6, 2020

@cmcaine I opened an upstream request last month actually https://gmplib.org/list-archives/gmp-bugs/2020-September/004865.html looks like there is a library bug, but the resolution wasn't clear on which route the library developers are planning on going regarding this patch.

@cmcaine
Copy link
Contributor

cmcaine commented Oct 6, 2020 via email

@StefanKarpinski
Copy link
Member

Not much you can do: chances are if you get to the point of OOMing, the process is going to crash, we just want the ability to do it more gracefully than a C abort call, which is something that a library should really never do. If GMP wants to be super careful, it could free anything that was allocated before returning an error, but it would also be fine to document that when an OOM error is returned some allocated memory may be lost.

@doronbehar doronbehar mentioned this pull request Oct 29, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

^(big(foo), bar) can cause SIGBART
7 participants