Coder Social home page Coder Social logo

data race in state tracking about goirc HOT 13 CLOSED

fluffle avatar fluffle commented on August 17, 2024
data race in state tracking

from goirc.

Comments (13)

fluffle avatar fluffle commented on August 17, 2024

State tracking is potentially racey -- see the other open issue. In current master, state tracker handlers are run strictly before any other handlers for a particular event, and the (default) foreground handlers are run in parallel for that same event while blocking the runloop goroutine. Are you using the "background" handlers? Otherwise the state handlers ought to be completely done with their writes by the time your reads can execute. Or, i've messed something up, which is entirely plausible. I've not actually used the state tracking in anger ever, it was just ... practice.

from goirc.

StalkR avatar StalkR commented on August 17, 2024

It doesn't use any handler, it's a goroutine which shares the *client.Conn, calls Me() to get *state.Nick then Channels() to get the list of channels.

from goirc.

fluffle avatar fluffle commented on August 17, 2024

The idea of scattering locks all throughout this code is making me feel a bit ill, despite all the races inherent in the current design. Some handwaving:

The API presented by the current state tracker is a little ... public, I think. I don't know that external users of the package need the ability to create arbitrary nicks or channels except via the tracker. I was considering making all the tracker methods return struct copies of Nicks and Channels rather than pointers to the originals. More of the actual tracking could be moved into the tracker where fewer, coarser locks would be required, and the copies would represent the state of the tracker at the point the method was called. Mutating them would not affect internal tracker state.

Just a vague idea. Thoughts? I might have some time over Christmas to hack on code ;-)

from goirc.

StalkR avatar StalkR commented on August 17, 2024

+1 on returning copies. You'll still need locks but you can have one RWMutex per struct and the usual lock/defer unlock on methods.

from goirc.

fluffle avatar fluffle commented on August 17, 2024

@lucy @StalkR @stzanpet PTAL at the diff between master and state-copy. There's more to come -- I'm working on the changes to client/. Or, I would be, but a friend bought me KSP for Christmas :-D

from goirc.

fluffle avatar fluffle commented on August 17, 2024

Client changes pushed and tested. Things seem fine. This will probably break code that uses the state tracker, but that's probably also a good thing.

@sztanpet (spelled it wrong last time, sorry)

from goirc.

sztanpet avatar sztanpet commented on August 17, 2024

cheers for trying to take everybodies viewpoint into account, and happy new year!
(my code continues to work fine btw, also including me as a contributor is far-fetched but appreciated)

from goirc.

StalkR avatar StalkR commented on August 17, 2024

Cool @fluffle! As expected goircbot breaks, I'll start a branch with the changes like you did and test, then we can merge to our master when ready.

from goirc.

StalkR avatar StalkR commented on August 17, 2024

Done and it seems to works fine. Ready to merge in master when you are!

from goirc.

StalkR avatar StalkR commented on August 17, 2024

ping @fluffle :)

from goirc.

fluffle avatar fluffle commented on August 17, 2024

Sorry, bit busy with life. And, well Minecraft ;-)
On 12 Feb 2015 19:40, "StalkR" [email protected] wrote:

ping @fluffle https://github.com/fluffle :)


Reply to this email directly or view it on GitHub
#49 (comment).

from goirc.

TrollWarlord avatar TrollWarlord commented on August 17, 2024

You replied but didn't accept the merge?

from goirc.

fluffle avatar fluffle commented on August 17, 2024

Accept what merge? I've not merged my "state-copy" branch into my master yet because I've been busy, as I said. Fortunately for you I've got some time spare this evening ;-)

from goirc.

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.