Skip to content
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

precompiled modules can't contain BigInts #15722

Closed
Keno opened this issue Mar 31, 2016 · 14 comments
Closed

precompiled modules can't contain BigInts #15722

Keno opened this issue Mar 31, 2016 · 14 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior compiler:precompilation Precompilation of modules maths Mathematical functions

Comments

@Keno
Copy link
Member

Keno commented Mar 31, 2016

__precompile__()
module Crash
const x = big"123"
__init__() = @show x
end # module
julia> using Crash
INFO: Precompiling module Crash...

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
__gmpz_get_str at /home/ubuntu/julia-debugger/usr/bin/../lib/libgmp.so (unknown line)
base at ./gmp.jl:518
[inline] at ./gmp.jl:509
showall at ./show.jl:1428
@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 1, 2016

Technically, this is a user error (for specifying __precompile__ incorrectly)

@Keno
Copy link
Member Author

Keno commented Apr 1, 2016

The user may have a pitch fork and know where you live.

@JeffBezanson
Copy link
Sponsor Member

Another reason to have fully native bigints that only call GMP for tricky functions.

@ChrisRackauckas
Copy link
Member

@vtjnash could you explain how a user could avoid this issue?

@yuyichao
Copy link
Contributor

Don't declare the the package as precompilable.

@ChrisRackauckas
Copy link
Member

Is there less heavy-handed way? If it's only a small part of the package which is causing it, that seems like overkill.

@Ismael-VC
Copy link
Contributor

Technically, this is a user error (for specifying precompile incorrectly)

@vtjnash technically this is a documentation error, I couldn't find a glimpse of bigs being discussed at the Module initialization and precompilation topic. ...issues and PRs are not documentation.

I'm sure bigs must have some kind of characteristic that makes it obvious (at least for you and a few others) that they wont work in this scenario, it would be better if you guys let others also know and why.

@yuyichao
Copy link
Contributor

Anything with pointers.

@yuyichao
Copy link
Contributor

And this is actually documented in the module doc in the section about precompilation

initializing global constants that involve pointers returned by external libraries

Documentation improvements are obviously welcome if that was not obvious/easy to find enough.

@ChrisRackauckas
Copy link
Member

ChrisRackauckas commented Aug 27, 2016

It's not just global constants though. In the other case I showed the constants were inside of a function inside of a module. (Unless constants in a function, when they are inline, somehow go global as an optimization I don't know about)

@ChrisRackauckas
Copy link
Member

initializing global constants that involve pointers returned by external libraries

It should mention "this includes" and a few examples from Base that it includes. What other Base types have this problem?

@TotalVerb
Copy link
Contributor

TotalVerb commented Feb 22, 2017

Given that @big_str is often emitted by the parser, it seems extremely brittle that having a large number in the AST somewhere can break precompilation. (this was #20749) This problem with large numbers is not covered by the existing initializing global constants that involve pointers returned by external libraries as, as far as I understand, function ASTs are not global constants, and should be documented separately.

module TestModule

function foo()
    170141183460469231731687303715884105728
    return 42
end

end

@JeffBezanson JeffBezanson added bug Indicates an unexpected problem or unintended behavior maths Mathematical functions and removed strings "Strings!" labels Feb 15, 2018
@JeffBezanson JeffBezanson added this to the 1.0.x milestone May 9, 2018
@JeffBezanson JeffBezanson changed the title big_str is dangerous in combination with compilation precompiled modules can't contain BigInts May 9, 2018
@Jutho
Copy link
Contributor

Jutho commented May 11, 2018

I also struggled with this over at WignerSymbols.jl, but managed to make it work by storing the constant big number in a Ref container and initializing it with an __init__ function. But some assistance in the documentation would have helped.

@vtjnash vtjnash self-assigned this May 11, 2018
@vtjnash
Copy link
Sponsor Member

vtjnash commented Jun 11, 2018

fix (for BigFloat) in #27331

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior compiler:precompilation Precompilation of modules maths Mathematical functions
Projects
None yet
Development

No branches or pull requests

9 participants