-
Notifications
You must be signed in to change notification settings - Fork 105
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
Cloning Dereferenced symbol may cause undefined behaviour. #13
Comments
My current thinking is that |
Keep in mind that you can also
Ew, that’s nasty. |
I've come to the conclusion that
If At this point, I think that the best implementation would require different structs for function symbols and data symbols. The function symbols could implement an unsafe method which allows them to be called. They cannot implement |
This is blocked on rust-lang/rust#29625. |
Since adding the
Clone
functionality I have been experimenting with cloningSymbol
s. I noticed that it is possible to clone a dereferencedSymbol
. This may cause undefined behavior. In particular this code is broken:This derefs func as
fn()
and calls theClone
implementation onfn()
rather than on theSymbol
object. Since theSymbol
'sLibrary
has already gone out of scope, the call can fail. I am currently investigating ways to get around this.To be clear, this problem is not caused by the new
Clone
functionality and it exists on earlier versions of the code. The problem seems to be with theDeref
implementation:In particular, the
transmute
drops lifetime information about theSymbol
but allows it to be copied from the raw function pointer.The text was updated successfully, but these errors were encountered: