Hello,
I'm trying to write a rust binding to a C library, and I'm getting exit code: 0xc0000005, STATUS_ACCESS_VIOLATION. I know this is a memory issue, but I can't spot where the problem is coming from. I've commented out all the code which I think might be causing the problem but... no luck.
the full code is here: https://github.com/ua-kxie/paprika/tree/dev. But I'll explain what I believe the code to be doing below:
my main function. note the comments annotating the problem lines
fn main() {
let ngspice = paprika::NgSpice::new(); // initialize library
let mut manager = NgSpiceManager::new(); // initialize manager
let a = paprika::PkVecinfoall{
count: 1,
};
manager.test(a); // this is fine
ngspice.init(&manager); // registers manager (callbacks) to the library
ngspice.command("source dcop1.cir"); // this is not fine
}
manager.test(a) is defined as follows:
fn test(&mut self, a: paprika::PkVecinfoall) {
self.vec_pkvecinfoall.push(a);
}
ngspice.command("source dcop1.cir") sends a command to the external library, which in turn calls the following callback:
fn cb_send_init_data(&mut self, pkvecinfoall: paprika::PkVecinfoall, count: i32, id: i32) {
let a = paprika::PkVecinfoall{
count: 1,
};
println!("{:p}", &a);
self.vec_pkvecinfoall.push(a); // if I comment out this line, the program exits normally
}
normally it would push pkvecinfoall into the vector, but trying to pinpoint the problem I've created a stripped down version of the structure locally without unsafe{}. As best as I can tell the program crashes when it tries to push a into the vector.
