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

LoadError with --inline=no #10238

Closed
jhasse opened this issue Feb 18, 2015 · 9 comments
Closed

LoadError with --inline=no #10238

jhasse opened this issue Feb 18, 2015 · 9 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@jhasse
Copy link
Contributor

jhasse commented Feb 18, 2015

When using GLFW.jl (Pkg.add("GLFW")) and callbacks, it only works with --inline=yes. Example code:

import GLFW

GLFW.Init()
window = GLFW.CreateWindow(1, 1, "")
GLFW.SetWindowSizeCallback(window, (_, width, height) -> println(""))

Which works fine except when --inline=no is set:

~ julia --inline=no test.jl 
INFO: loaded GLFW 3.0.4 X11 GLX glXGetProcAddress clock_gettime /dev/js shared from /home/jhasse/.julia/v0.4/GLFW/deps/usr64/lib/libglfw
ERROR: LoadError: type Void has no field callbacks
 in SetWindowSizeCallback at /home/jhasse/.julia/v0.4/GLFW/src/util.jl:34
 in SetWindowSizeCallback at /home/jhasse/.julia/v0.4/GLFW/src/util.jl:44
 in include at ./boot.jl:249
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:319
 in _start at ./client.jl:403
while loading /home/jhasse/test.jl, in expression starting on line 5

I'm sorry I can't figure out where exactly it goes wrong as I don't quite understand what is happening inside util.jl. Maybe @jayschwa knows more.

@pao
Copy link
Member

pao commented Feb 18, 2015

Which Julia version?

@jhasse
Copy link
Contributor Author

jhasse commented Feb 19, 2015 via email

@pao
Copy link
Member

pao commented Feb 19, 2015

Might this be related to Void/Nullable/null/Undef/something else that changed recently in the nothingness department, @JeffBezanson?

@jayschwa
Copy link
Member

Sorry for the complexity of that macro in util.jl. If I have some time in the next few days, I'll try to reproduce and boil it down to a kernel.

@timholy
Copy link
Sponsor Member

timholy commented Feb 19, 2015

There are many closed issues about --inline=no, but it seems that they have been fixed (#9536). I'm not sure when +3399 is from, but it's possible you may want to upgrade. If not fixed, then you have a new one...

@jhasse
Copy link
Contributor Author

jhasse commented Feb 19, 2015 via email

@jayschwa
Copy link
Member

I boiled down the problem and devised a simple test:

using Base.Test

obj = "some object"
ptr_void = pointer_from_objref(obj)
ptr_type = convert(Ptr{typeof(obj)}, ptr_void)

x = unsafe_pointer_to_objref(ptr_void)
@test typeof(x) == typeof(obj)
@test x == obj

x = unsafe_pointer_to_objref(ptr_type)
@test typeof(x) == typeof(obj)
@test x == obj

unsafe_pointer_to_objref normally returns obj regardless if the given pointer is Void or typed. However, for a typed pointer when --inline=no, unsafe_pointer_to_objref returns nothing. This causes a failure in GLFW.jl at https://github.com/JuliaGL/GLFW.jl/blob/master/src/glfw3.jl#L294 since the ccall is defined as returning a typed pointer.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Feb 22, 2015

this seems likely to be fixed by #9986, when the codepath taken by that function is changed from an intrinsic to a ccall

@JeffBezanson JeffBezanson added the bug Indicates an unexpected problem or unintended behavior label Mar 7, 2015
@jakebolewski
Copy link
Member

This works for me now, please respond if this is still an issue.

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
Projects
None yet
Development

No branches or pull requests

7 participants