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

Context dropped while still referred to by Queue or Program, causing panics #165

Open
aabizri opened this issue Sep 22, 2019 · 0 comments
Open

Comments

@aabizri
Copy link

aabizri commented Sep 22, 2019

When creating a ProQue for example, and making it go out of scope (and be dropped), the Context referred to by Queue or Program is dropped, making calls like Queue::context() or Program::info(ocl::core::ProgramInfo::Context) panic ! (tested on ocl 0.19)

Panic message example:

################################ OPENCL ERROR ############################### 

Error executing function: clRetainContext  

Status error code: CL_INVALID_CONTEXT (-34)  

Please visit the following url for more information: 

https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clRetainContext.html#errors  

############################################################################# 
', src/libcore/result.rs:1165:5
stack backtrace:
  [... omitted]
  15: core::result::Result<T,E>::unwrap
             at /rustc/96d07e0ac9f0c56b95a2561c6cedac0b23a5d2a3/src/libcore/result.rs:933
  16: ocl_core::types::abs::Context::from_raw_copied_ptr
             at /home/aabizri/.cargo/registry/src/github.com-1ecc6299db9ec823/ocl-core-0.11.2/src/types/abs.rs:475
  17: ocl_core::types::abs::CommandQueue::context::{{closure}}
             at /home/aabizri/.cargo/registry/src/github.com-1ecc6299db9ec823/ocl-core-0.11.2/src/types/abs.rs:605
  18: core::result::Result<T,E>::map
             at /rustc/96d07e0ac9f0c56b95a2561c6cedac0b23a5d2a3/src/libcore/result.rs:512
  19: ocl_core::types::abs::CommandQueue::context
             at /home/aabizri/.cargo/registry/src/github.com-1ecc6299db9ec823/ocl-core-0.11.2/src/types/abs.rs:605
  20: ocl::standard::queue::Queue::context
             at /home/aabizri/.cargo/registry/src/github.com-1ecc6299db9ec823/ocl-0.19.3/src/standard/queue.rs:68
  21: ocl_proque_drop_error::main
             at src/main.rs:19
  [... omitted]

Minimum example for replication (using Queue but I also tested with Program)

extern crate ocl;

const KERNEL_SRC: &str = r#"
__kernel void nothing() {}
"#;

fn create_queue() -> ocl::Queue {
    ocl::ProQue::builder()
        .src(KERNEL_SRC)
        .dims(1 << 20)
        .build()
        .unwrap()
        .queue()
        .clone()
}

fn main() {
    let queue = create_queue();
    queue.context();
}

Other example using Program: main.txt

My guess is that as raw pointers are used, the compiler doesn't keep track.

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

1 participant