-
Notifications
You must be signed in to change notification settings - Fork 166
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
Array size not in manifest #2070
Comments
This should not be a segfault; it should be a proper dynamically checked error. Does it really segfault with cargo-futhark? It would be nice to provide some more information like this in the manifest, but it's not immediately straightforward what it should look like. We would like to support all possible invariants, such as requiring two arrays that have the same size (but is not otherwise constrained). One solution would be to just provide the actual Futhark type, and let sufficiently smart bridges figure it out. |
Just checked again and got this backtrace:
Using current git futhark-cargo (crates version is broken).
|
Speaking as an application developer, having a basic constraint describing only fixed size arrays would already be great. If not the binding, then I have to implement the convention by hand anyway. |
How is that Rust code type correct? The third argument to the entry point must be a one-dimensional array, but you pass it a two-dimensional array. |
Wait, no, I misread. |
I am still confused, however. What does |
I presume |
Looking at the backtrace again, the problem appears in Drop/free. I think this makes it quite likely that the bindings are incorrect. I'll take a closer look when I have the time. |
My guess is that the entry point fails (as it should), meaning the array it returns (at the C level) is uninitialised, which is not handled properly by cargo-futhark. |
Adding a null pointer check seems to work. It's surprising to see that the output array is allocated in the call to the entry function, but I guess valid. Typically C interfaces expect the caller to provide a pre-allocated array. |
That would only be possible if the C API exposed the size of the various structs, which raises all kinds of problems. It's an important feature that all allocation is done by Futhark. |
What requirements should a proposed solution fulfill? You already listed all constraints I'm aware of :) How does providing the Futhark type help when 2 arrays are to have the same size? |
A futhark function type [n]i32 -> [n]bool -> ... explicitly expresses that the two arguments must have the same shape. If The question is how it should be encoded in the manifest. The |
When a function has a fixed-length array argument like
(height: [16]i32)
, the manifest does not reflect that, and instead suggests that the array is dynamic length: []i32. This prevents wrappers from verifying that the arrays received are of the correct size, and results in the code simply segfaulting. Noticed with cargo-futhark.The text was updated successfully, but these errors were encountered: