Skip to content

Race condition ? #32

@janpfeifer

Description

@janpfeifer

While reading the code, I noticed what I think is a race condition in the Put() loop, in lines 465:

	for {
		oldHead := P(shard.Head.Load())
		if shard.Head.CompareAndSwap(oldHead, obj) {  // (1)
			obj.SetNext(oldHead)                      // (2)
			return
	}

If between (1) and (2) another goroutine (using the shardID) retrives the obj and starts to use it,
this breaks.

Shouldn't (2) come before (1) ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions