GithubHelp home page GithubHelp logo

Comments (6)

Koka avatar Koka commented on August 27, 2024

Looks like it's totally unsafe to allocate multiple environments. See https://odbcrouter.com/api/index.shtml?SQLAllocEnv for example.

On operating systems that support multiple threads, applications can use the same henv on different threads and drivers must therefore support safe, multithreaded access to this information. The application passes the henv value in all subsequent calls that require an henv.
There should never be more than one henv allocated at one time and the application should not call SQLAllocEnv when there is a current valid henv. If the application calls SQLAllocEnv with a pointer to a valid henv, the driver overwrites the henv without regard to its previous contents. (ODBCSDK/OverDRIVER returns the same handle.)

from odbc-rs.

pacman82 avatar pacman82 commented on August 27, 2024

Seems to be true. The race conditions in the tests seem to indicate the same :-(. Despite having to prevent the user from instantiating the wrapper class more than once, this raises another troubling issue: Our library probably would not compose safely with other ODBC wrappers. I stated the issue with a call for help in this reddit thread. Maybe you want to weigh in.

from odbc-rs.

Koka avatar Koka commented on August 27, 2024

@pacman82 I think situation when someone uses two ODBC wrappers simultaneously in the same process is pretty exotic and probably the man who does this knows well what he's doing. It's good enough to prevent multiple instantiation of rust odbc environment wrapper and trust end user to not screw things up with another wrapper. And we need to ensure that our environment wrapper can be shared between threads comfortably - as it's allowed by odbc contract and user will have no ability to instantiate second environment.

from odbc-rs.

Koka avatar Koka commented on August 27, 2024

And may be we should allow unsafe construction of our wrapper from raw environment handle which can be allocated by another wrapper for example to give end user ability to use our wrapper with externally constructed environment?

from odbc-rs.

pacman82 avatar pacman82 commented on August 27, 2024

Yesterday I discovered a bug I introduced in my fork (shame on me). Since fixing it I do no longer experience any data races while running tests. Reading the ODBC reference I did still not find any indication that allocating more than one Environment is UB. Yet we both did find secondary documentation claiming otherwise. In would suggest "in dubio pro reo": Our growing number of tests should eventually show if multiple Environments are a problem. Especially since they run in parallel. Until the tests show this to be the case I'm willing to assume multiple Environments are safe.

If you agree I would regard this issue as closed.

from odbc-rs.

Koka avatar Koka commented on August 27, 2024

Ok, let's leave to end user as original API do.

from odbc-rs.

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.