-
Notifications
You must be signed in to change notification settings - Fork 26
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
let ccall get the pointers using unsafe_convert #349
Conversation
Sorry for the slow response -- I do not understand enough about Julialang's GC behavior well enough to fully follow #347. E.g. why do we need to I've tried reading up about it (without much success) and maybe it's better for me to ask for help/clarification here. |
As far as I understand, we should've used either the preserve or unsafe_convert strategy already. Now with a more aggressive GC in the new Julia version our old approach causes actual segfaults, but the unsafe situation was always there. The problem was, when we take out the obj.ptr field, the compiler cannot see anymore that obj itself is still in use, and might call the finalizer on it. We can stop it from doing that with the preserve annotation. But we can also pass obj to ccall, and ccall is implemented in a way that does a similar annotation for us already. So that is the easier option. To be able to use that we only need to help ccall with converting obj to ptr, and pass obj instead of obj.ptr to ccall. https://docs.julialang.org/en/v1/base/base/#Base.GC.@preserve |
Thank you for the explanation, really helpful! From what I understand (explained below), I agree with cloning here.
|
I'm not sure exactly what to change to the createlinearring functions. If anyone has ideas, feel free to push to this branch.
Is that not a kind of method that would be good to add? Reading the |
Just to explain the special casing a little GDAL swaps the wkbLinearRing type to wkbLineString after creation, so we have to do that too with these specialised methods. Probably adding that method is a good fix? Although I haven't totally followed these changes. |
I'll give it a shot and let you know when I'm done, thanks! |
There isn't any logical changes here; just refactoring.
They do not follow the patterns for the other geometry types.
Namely (i) to finalize the internal geometries that were cloned and (ii) to appropriately parameterize the geometries returned.
`_infergeomtype(...)` should be operating on pointers and not geometries.
Great, thanks. Your changes look good to me, and fix the issue. The remaining test failures and error are unrelated to this PR, so I'd propose to handle them in a different PR. Specifically the error that is only on nightly "type Stateful has no field taken" is this upstream issue: meggart/DiskArrays.jl#80. The rest is related to GDAL 3.6, #345, I updated that with some more info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the work here and explanations of the remaining test failures!
Adress #347, alternative approach to #348, based on discussion in #347.
Still has a few errors, like this:
So probably we need to add some constructors to handle this case. Not sure how to best do that safely, i.e. should we clone here? If not, how do we track lifetimes?