FFI C Interface fails with code 1 on my Laptop, not on a desktop


#1

Now this is an issue really hard to replicate and I have no idea how to address. So I’m trying use arrayfire library which has a rust interface: https://github.com/arrayfire/arrayfire-rust. The problem is that on my laptop I consistently am getting exit code 1, which however tested on another mahcine I don’t get. Suprisingly this happens with a very simple program:

extern crate arrayfire as af;

use std::time::Instant;
use af::*;

fn main() {
    set_device(0);
    info();
}

The output on both machine is the same (e.g. the info() call prints correctly), however on my laptop for some reason the program always exits with 1 rather than 0. I currently have no idea how to debug this, but is there anyway that I can get an understanding of what is causing it?


#2

This seems to be a problem with the library. You should probably search for the issue on github and if nothing pops up, open an issue yourself.
This forum is for more general Rust talk. Most of us probably don’t have a clue what “arrayfire” even does :wink:


#3

Ah I agree, but I already asked a few people and the problem is that the issue is not reproducable on anything except my laptop (they’ve tried it on their machines, I’ve tried on my desktop). I do understand, that most people would not really care or need to care, but in such cases where I just get an exit code of 1 is there any guidence on how to debug it? I’m more interested in how to approach the problem, as in such subtle cases who knows if it is even solvable.


#4

You don’t say which platform you’re on. Assuming unix, you can use general debugging tools such as strace and gdb.


#5

Thanks I’m on Linux and I will look into those options.


#6

Just to give some update, someone from the IRC channel suggested me valgrind, and it seems to found that there is an invalid access in the underlying OpenCL library from Intel. Is there something equivalent to that under cargo?


#7

You can run cargo-built executables under Valgrind. Tell Valgrind to run ./target/debug/yourexecutablename or ./target/release/yourexecutablename.

For release executables you might want to have debug symbols. You can get them by adding [profile.release] debug=true in Cargo.toml.