bytecodealliance / wamr-rust-sdk

Apache License 2.0
33 stars 10 forks source link

Lifetime issues #75

Open AlixANNERAUD opened 2 days ago

AlixANNERAUD commented 2 days ago

I think there's a lifetime issue with Instance, Module and Runtime, since Instance can outlive Module, and Module can outlive Runtime which leads to UB/segfault. A lifetime should be added to each object type and propagated to children "objects" (using using PhatomData marker since we are dealing with pointers). If you are ok with that, I can do the PR RN.

lum1n0us commented 2 days ago

there's a lifetime issue with Instance, Module and Runtime, since Instance can outlive Module, and Module can outlive Runtime which leads to UB/segfault

I don't fully understand those points. Could you please provide us with more details or an example?

AlixANNERAUD commented 1 day ago

Lifetime in rust needs to be defined explicitly in rust when dealing with pointers / references. The compiler always ensure that an explicit lifetime is defined for references in a struct but not for raw pointers.