Crashed trying to use an FFI function that takes multiple arrays
Closed this issue · 1 comments
ArseniyKorobenko commented
crash log:
The application panicked (crashed).
Message: called `Option::unwrap()` on a `None` value
Location: C:\Users\███\.cargo\registry\src\index.crates.io-6f17d22bba15001f\uiua-0.9.2\src\ffi.rs:604
Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Error: The interpreter has crashed!
Hooray! You found a bug!
Please report this at http://github.com/uiua-lang/uiua/issues/new or on Discord at https://discord.gg/9CU2ME4kmn.
code:
test.ua:3:7
at test.ua:3:7
3 | Lib ← &ffi ⊂□"calcdll.dll"
Uiua code:
# Experimental!
Lib ← &ffi ⊂□"calcdll.dll"
Add ← Lib {"int" "Add" "int" "int"} {⊙∘}
Add 5 6 # works, 11
Sum ← Lib {"int" "Sum" "const int:1" "int"}
Sum {[1 2 3 4 5]} # works, 15
# crashes
Test ← Lib {"void" "test" "const int*" "int" "const int*" "int" "int*" "int"}
Test {:⧻.[0 1 2 3] :⧻.[4 1 1 0] :⧻.[0 0 0 0 0 0 0 0 0 0 0 0]}
# doesn't work either
Test ← Lib {"void" "test" "const int:1" "int" "const int:3" "int" "int:5" "int"}
Test {[0 1 2 3] [4 1 1 0] [0 0 0 0 0 0 0 0 0 0 0 0]}
C code:
#define CALL __cdecl
int CALL Add(int a, int b) {
return (a + b);
}
int CALL Sum(const int* arr, int len)
{
int s = 0;
for (int i = 0; i < len; i++)
s+=arr[i];
return s;
}
void CALL test(
const int* a, int len_a,
const int* b, int len_b,
int* c, int len_c)
{
for (int i = 0; i < len_c; i++)
c[i] = i;
}