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

Fix documenting baremodules #13067

Merged
merged 1 commit into from
Sep 11, 2015

Conversation

MichaelHatherly
Copy link
Member

Prior to this fix attempting to document baremodules results in an infinite error message plus segfault when trying to escape:

julia> "..." baremodule M end

This fix imports call and @doc into the module automatically.

Also makes documenting empty baremodules an error since that was also causing segfaults. That limitation won't impact any real-world code though.

Tests and documentation updates as well.

Prior to this fix attempting to document baremodules results in an infinite
error message plus segfault when trying to escape:

    julia> "..." baremodule M end

This fix imports `call` and `@doc` into the module automatically.

Also makes documenting empty baremodules an error since that was also
causing segfaults. That limitation won't impact any real-world code though.

Tests and documentation updates as well.
@tkelman tkelman added the docsystem The documentation building system label Sep 11, 2015
jakebolewski added a commit that referenced this pull request Sep 11, 2015
@jakebolewski jakebolewski merged commit 65365fb into JuliaLang:master Sep 11, 2015
@carnaval
Copy link
Contributor

I think if pure julia can segfault there is still a bug to fix somewhere ? Or did I misunderstood ?

@jakebolewski
Copy link
Member

He catches that case and throws an error. Was going to open another issue for the bare mode segfault.

tkelman pushed a commit that referenced this pull request Sep 11, 2015
Prior to this fix attempting to document baremodules results in an infinite
error message plus segfault when trying to escape:

    julia> "..." baremodule M end

This fix imports `call` and `@doc` into the module automatically.

Also makes documenting empty baremodules an error since that was also
causing segfaults. That limitation won't impact any real-world code though.

Tests and documentation updates as well.

(cherry picked from commit 8edd917)
ref #13067
@MichaelHatherly
Copy link
Member Author

@carnaval, pushing the :(import Base: call, @doc) onto the front of the baremodule arg list instead

diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl
index 6e6a4db..915bc92 100644
--- a/base/docs/Docs.jl
+++ b/base/docs/Docs.jl
@@ -471,8 +471,7 @@ function moddoc(meta, def, name)
         def = unblock(def)
         block = def.args[3].args
         if !def.args[1]
-            isempty(block) && error("empty baremodules are not documentable.")
-            insert!(block, 2, :(import Base: call, @doc))
+            unshift!(block, :(import Base: call, @doc))
         end
         push!(block, docex)
         esc(Expr(:toplevel, def))

and then doing

julia> "..." baremodule M end

gives the following error. I'm having trouble reducing it much more than that though.

ERROR: fatal: error thrown and no exception handler available.
Base.MethodError(f=convert, args=(SimpleVector, Expr(:toplevel, Expr(:import, :Base, :call)::Any, Expr(:import, :Base, :@doc)::Any)::Any))
rec_backtrace at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
jl_throw at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: 0x7f75ecbce0e3)
unknown function (ip: 0x7f75ecbce137)
unknown function (ip: 0x7f75ecbce36e)
abstract_call_gf at ./inference.jl:687
unknown function (ip: 0x7f75e9dc4460)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call at ./inference.jl:842
abstract_apply at ./inference.jl:805
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call at ./inference.jl:873
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_eval_call at ./inference.jl:928
abstract_eval at ./inference.jl:955
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_eval_call at ./inference.jl:900
abstract_eval at ./inference.jl:955
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf_uncached at ./inference.jl:1616
unknown function (ip: 0x7f75e9d9f160)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1333
unknown function (ip: 0x7f75e9d99c96)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1283
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call_gf at ./inference.jl:733
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call at ./inference.jl:873
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_eval_call at ./inference.jl:928
abstract_eval at ./inference.jl:955
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf_uncached at ./inference.jl:1616
unknown function (ip: 0x7f75e9d9f160)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1333
unknown function (ip: 0x7f75e9d99c96)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1283
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call_gf at ./inference.jl:733
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call at ./inference.jl:873
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call at ./inference.jl:890
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_eval_call at ./inference.jl:928
abstract_eval at ./inference.jl:955
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf_uncached at ./inference.jl:1616
unknown function (ip: 0x7f75e9d9f160)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1333
unknown function (ip: 0x7f75e9d99c96)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1283
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call_gf at ./inference.jl:733
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call at ./inference.jl:873
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_eval_call at ./inference.jl:928
abstract_eval at ./inference.jl:955
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_interpret at ./inference.jl:1104
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf_uncached at ./inference.jl:1543
unknown function (ip: 0x7f75e9d9f160)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1333
unknown function (ip: 0x7f75e9d99c96)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1283
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call_gf at ./inference.jl:733
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call at ./inference.jl:873
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_eval_call at ./inference.jl:928
abstract_eval at ./inference.jl:955
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_interpret at ./inference.jl:1104
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf_uncached at ./inference.jl:1543
unknown function (ip: 0x7f75e9d9f160)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1333
unknown function (ip: 0x7f75e9d99c96)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1283
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call_gf at ./inference.jl:733
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_call at ./inference.jl:873
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
abstract_eval_call at ./inference.jl:928
abstract_eval at ./inference.jl:955
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf_uncached at ./inference.jl:1616
unknown function (ip: 0x7f75e9d9f160)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf at ./inference.jl:1333
unknown function (ip: 0x7f75e9d99c96)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
typeinf_ext at ./inference.jl:1277
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: 0x7f75ecbcd2f8)
unknown function (ip: 0x7f75ecbcdbf4)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
anonymous at client.jl:88
with_output_color at util.jl:313
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
display_error at client.jl:86
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
_start at ./client.jl:458
unknown function (ip: 0x7f75e9f8a409)
jl_apply_generic at /home/mike/usr/julia/master/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: 0x401a37)
unknown function (ip: 0x40163f)
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
unknown function (ip: 0x401689)
unknown function (ip: (nil))

@MichaelHatherly MichaelHatherly deleted the mh/baremodule-doc branch September 11, 2015 15:41
@tkelman
Copy link
Contributor

tkelman commented Sep 13, 2015

backported in #13072

@jakebolewski
Copy link
Member

@MichaelHatherly @carnaval the error comes from the fact that the global jl_an_empty_cell global is being mutated.

* thread #1: tid = 0x18ecb0f, 0x000000010002025c libjulia-debug.dylib`ml_matches(ml=0x000000010685f610, type=0x0000000106886150, name=0x00000001049159a8, lim=4) + 252 at gf.c:1915, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x000000010002025c libjulia-debug.dylib`ml_matches(ml=0x000000010685f610, type=0x0000000106886150, name=0x00000001049159a8, lim=4) + 252 at gf.c:1915
   1912     JL_GC_PUSH4(&t, &matc, &env, &ti);
   1913     int len=0, i;
   1914     if (name == jl_symbol("get"))
-> 1915         jl_breakpoint(name);
   1916     while (ml != (void*)jl_nothing) {
   1917         // a method is shadowed if type <: S <: m->sig where S is the
   1918         // signature of another applicable method
(lldb) p jl_(t)
Array{Any, 1}[Expr(:toplevel, Expr(:import, :Base, :call)::Any, Expr(:import, :Base, :@doc)::Any)::Any, Expr(:macrocall, :@doc, " Doc ", :Foo)::Any]

@yuyichao
Copy link
Contributor

I actually just get an BoundsError on insert!.

@jakebolewski
Copy link
Member

You have to apply the patch to reproduce the bug. As the array is zero length, it is expected you will get a bounds error with insert!.

@yuyichao
Copy link
Contributor

Ahh.. I somehow missed the second line of the patch...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docsystem The documentation building system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants