GithubHelp home page GithubHelp logo

Missing Gdal dataset open flags about gdal HOT 6 CLOSED

georust avatar georust commented on May 25, 2024
Missing Gdal dataset open flags

from gdal.

Comments (6)

rmanoka avatar rmanoka commented on May 25, 2024

The bitflags approach is very cool; I'd opened a similar issue but this is more comprehensive, so I'm closing it. There is one issue with the open_ex options: GDAL_OF_SHARED that needs to be discussed (see below).

Sharing Issue

GDAL since 2.4 allows Dataset to be accessed from different threads, as long as only one thread accesses it at any time (ref. discussion). In this crate, we impl Send on Dataset to reflect that we can pass it to another thread, but not Sync so it is not accessed from two threads at the same time.

However, the GDAL_OF_SHARED option allows this to be subverted. We might open the same dataset twice with the shared option, and then pass one of the Dataset handles to another thread. This could lead to undefined behaviours as we are accessing a non-thread-safe data-structure from different threads simultaneously.

The simplest solution I could think of is to remove GDAL_OF_SHARED from the bitflags, thus not allowing it in the flags. Then, we could add a flag in DatasetOptions which can only be set via an unsafe method. This way, we allow shared open, if the user knows what they're doing, and there's no way to get UB via safe rust.

from gdal.

jdroenner avatar jdroenner commented on May 25, 2024

wow this is a really cool solution. I think @rmanoka is right. we should remove the shared bitfag and add an unsafe method to DatasetOptions to enable this feature.

from gdal.

dmarteau avatar dmarteau commented on May 25, 2024

I do agree that GDAL_OF_SHARED defeat the purpose of multithreading safety and I'm also in favor te remove it.

from gdal.

dmarteau avatar dmarteau commented on May 25, 2024

Then, we could add a flag in DatasetOptions which can only be set via an unsafe method

Amha, this is even not necessary and it would be better to rely on rust safe way of handling shared access to dataset.

from gdal.

jdroenner avatar jdroenner commented on May 25, 2024

i guess we can add a special method for shared later ( if we need it)

from gdal.

rmanoka avatar rmanoka commented on May 25, 2024

Amha, this is even not necessary and it would be better to rely on rust safe way of handling shared access to dataset.

Sounds good; bitflags already has an unsafe fn from_bits_unchecked that allows this anyway.

from gdal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.