Git Product home page Git Product logo

Comments (6)

pitrou avatar pitrou commented on June 3, 2024 1

@colesbury @swtaarrs @corona10

from cpython.

colesbury avatar colesbury commented on June 3, 2024 1

@swtaarrs, I don't think you need to annotate PyMutex. I think it's more likely something like sem_clockwait not being supported by TSan.

colesbury/nogil-3.12@7507a77

from cpython.

colesbury avatar colesbury commented on June 3, 2024 1

Oh, I missed that. I'm curious if annotations for PyMutex fix this, but it looks to me like a data race:

T1: Writes pending->calls_to_do (nonatomic, but holding pending->mutex);
T2: Reads pending->calls_to_do (atomic, but not holding pending->mutex);

Either T1 needs an atomic write or T2 needs to hold pending->mutex.

from cpython.

swtaarrs avatar swtaarrs commented on June 3, 2024 1

(heh, I saw your comment pop up as I clicked to post mine. sounds like we agree!)

TSAN still doesn't like the nonatomic increment even with PyMutex annotated (I verified that the annotations are working, since the error message now says that it holds the relevant PyMutex during the bad write).

I'm going back to my initial thought was that this is a real data race. We shouldn't be mixing nonatomic writes with atomic reads, even if it works out in practice. Changing the increment and decrement of pending->calls_to_do to atomic gets rid of the error, and I wouldn't expect it to be a performance issue.

from cpython.

swtaarrs avatar swtaarrs commented on June 3, 2024

It looks like the root of the issue here is that tsan doesn't know about PyMutex, which is used to protect the data member being mutated here. I believe I've found the set of function calls used to annotate mutex implementations, so I'll work on adding those to PyMutex.

from cpython.

swtaarrs avatar swtaarrs commented on June 3, 2024

@colesbury That's already in main. Any other ideas? The annotations look pretty straightforward so I'll give them a try.

from cpython.

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.