-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Base.unsafe_convert(Ptr, ::Vector}
started throwing on master
#51996
Comments
Dup of #51962 I think |
It seems like this is some sort of reinterpret call? It is not well-defined what happens if you call In the particular |
@vtjnash Thanks for explaining! To answer your question, yes, what we try to do here is to have a |
The operation is illegal in most programming languages (for example, in C it is undefined behavior), so Julia is no different in that respect. That is why |
Note that the GC property you must ensure is not "the source object is not outlived by the reinterpreted one" but "the lifetime of the source object is exactly identical to the lifetime of the reinterpreted one" |
specifically because if the reinterpreted one dies first, gc might try to free the reinterpreted one. |
There is no free on the reinterpreted one. But if the reinterpreted one dies first, the gc may forget to traverse the source one, resulting in part of it getting freed earlier than you expected |
Can't repro anymore. Though I guess the idea is still to deprecate at some point? |
I think this was fixed by #53589 |
Hey folks,
This used to work prior to 1.11:
But now it throws:
To give more context, we do something like:
Which would on 1.9 / 1.10 yield:
But throws in the
unsafe_convert
step on master.Is this expected? This broke our master-tracking CI.
Would a reasonable fix for this be rewriting the
unsafe_convert
step to(adding the
pointer(...)
call)?Is this fundamentally impossible to make safe and there is a better idiom for this kind of unsafe conversion?
Thanks!
The text was updated successfully, but these errors were encountered: