Hello, I'm trying to add an effect that executes a Command using Rust platform code. I got it working with just the command arg. But I wanted to pass in a list of args. But I keep getting a seg fault. My Effect definition is
exec : Str, List Str -> Effect (Result Str {})
and my Rust code is
pub extern "C" fn roc_fx_exec(cmd: &RocStr, args: RocList<RocStr>) -> RocResult<RocStr, ()> {
If I remove the args
param from the code it compiles and runs fine. But with the RocList it seg faults.
My first gut reaction is that it is related to borrowing vs not borrowing(aka pass by reference or not). Should the RocList
be &RocList
?
Just seems strange that the string is passed by reference, but not the list.
no that is what the llvm codegen does at the moment
at least, internally
hmm the C interface might do something different. Worth a try
@Brendan Hansknecht that worked thanks, but now I'm getting a seg fault trying to change the &RocList<&RocStr>
to a Vec<String>
Here's the code I'm trying:
let rust_args: Vec<String> = args.as_slice().to_vec().iter().map(|x| x.as_str().to_string()).collect();
I think it should be &RocList<RocStr>
@Brendan Hansknecht that did it! Thanks so much!
Rob has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC