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

Current Event callback uses undefined behaviour #86

Closed
vchuravy opened this issue Nov 6, 2015 · 5 comments
Closed

Current Event callback uses undefined behaviour #86

vchuravy opened this issue Nov 6, 2015 · 5 comments

Comments

@vchuravy
Copy link
Member

vchuravy commented Nov 6, 2015

I learned today [1] that the solution I implemented for user callbacks in [2] is using undefined/illegal behaviour.
I am quite amazed that it worked as long as it did...

code_llvm(OpenCL.event_notify, (OpenCL.CL_event, OpenCL.CL_int, Ptr{Void}))

%7 = load %jl_value_t*** @jl_pgcstack, align 8

I am not quite sure how to solve that problem without reimplementing Base.SingleAsyncWork since we can't pass along evt_id::CL_event, status::CL_int.

@jakebolewski Any ideas?

[1] https://groups.google.com/forum/#!topic/julia-dev/9J1GYfCyVpE
[2]

OpenCL.jl/src/event.jl

Lines 97 to 106 in f529546

function event_notify(evt_id::CL_event, status::CL_int, julia_func::Ptr{Void})
# Obtain the Function object from the opaque pointer
callback = unsafe_pointer_to_objref(julia_func)::Function
# In order to callback into the Julia thread create an AsyncWork package.
cb_packaged = Base.SingleAsyncWork(data -> callback(evt_id, status))
# Use uv_async_send to notify the main thread
ccall(:uv_async_send, Void, (Ptr{Void},), cb_packaged.handle)
end

@dfdx
Copy link
Contributor

dfdx commented Nov 11, 2015

Can it be the reason for segfault in tests? (note that I commented out possibly erroneous tests for arrays).

@vchuravy
Copy link
Member Author

Yes that is entirely possible and probably my fault. I am going to look
into this. How often do you see it occur?

On Thu, 12 Nov 2015 07:13 Andrei Zhabinski [email protected] wrote:

Can it be the reason for segfault in tests
https://travis-ci.org/JuliaGPU/OpenCL.jl/jobs/90612668? (note that I
commented out possibly erroneous tests for arrays).


Reply to this email directly or view it on GitHub
#86 (comment).

@dfdx
Copy link
Contributor

dfdx commented Nov 12, 2015

It is pretty reproducible in Travis (40% of time, in other 60% error is not printed, but build fails, so it may also be caused by segfault). Though, currently I don't have access to a GPU-enabled computer, so cannot test it locally.

Note 2 things:

  • segfault-test branch is a copy of master with array tests commented out
  • segfault occurs only for Julia v0.4 on Linux, nightly build and Mac are not affected (according to Travis)

@vchuravy
Copy link
Member Author

@dfdx Sorry I completely missed the point you were trying to make. I though #87 was already merged and was about to investigate the seqfault you mentionend and wondered why it is still the old code. I think it is time to merge #87 now and that should hopefully solve your issue.

@dfdx
Copy link
Contributor

dfdx commented Nov 17, 2015

Thanks, that error has gone now. However, I encounter another (minor) issue which might be related to even callbacks - see #92 .

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

No branches or pull requests

2 participants