Comments (7)
You are right: right
won't be GC-ed. I was wrong about it.
As you mentioned, the issue is that left
or right
has a chance it is already removed from the list when this method is called.
from hashmap.
Thanks for your bug report, indeed the old implementation had some issues, the current dev branch has a singly linked list which should not have those issues anymore. Please review and create a new ticket if you see any other issue, thanks!
from hashmap.
There is only a bug_grow_insert
branch. Is it the dev branch you mentioned above?
from hashmap.
Since main
branch is still the default branch, closing this issue without fixing it is inappropriate for users.
Please keep an issue of an unsolved problem open, to let users know there is a risk in using this lib.
from hashmap.
Main is the default/dev branch, tags are releases. Since the code now uses a singly linked list, this issue is not present or valid anymore and gets closed.
from hashmap.
I'm afraid the problem is still there as long as it uses a pointer address to identify an unchanged node:
The right
has a chance it has been changed, but the address is the same.
Please keep this issue open until it's been fixed.
func (l *List[Key, Value]) insertAt(element, left, right *ListElement[Key, Value]) bool {
if left == nil {
left = l.head
}
element.next.Store(right)
if !left.next.CompareAndSwap(right, element) {
return false // item was modified concurrently
}
l.count.Add(1)
return true
}
from hashmap.
Thanks for reviewing it again. I will reopen the issue once I can clearly see/understand the problem.
The only issue I can see here is that if the function insertAt
returns false due to a concurrent change of the next pointer of the left node, the inserting should be retried but currently the callers do not do that. Is this what you are referring to?
Edit: HashMap.insertElement
already does retry in case of concurrent interfering changes.
Other than that I can see no issue of using a pointer to identify a node. If there is still a reference/pointer to the node object, the GC should not garbage collect the object and reuse it.
from hashmap.
Related Issues (20)
- can it be write safe ? HOT 1
- Lost Set() while growing HOT 2
- Lost add when deleting concurrently HOT 7
- Having break statement while iterating causes goroutine leak HOT 1
- .Get on absent key fatalpanics HOT 1
- the speed for set is really really really low HOT 5
- panic: unsupported key type *foo HOT 3
- Lost writes on table growth HOT 4
- Getting this error when there are many go routines trying to access the value HOT 1
- Panic with Mac M1 and Delve debuger HOT 1
- Thank you HOT 1
- minor version updates break the API HOT 1
- Hang when using GetOrInsert and DEL HOT 3
- Support compound keys
- invalid recursive type atomic.Pointer HOT 3
- 1.19.4 HOT 2
- Unexpected behaviors under large number of data
- [BUG] - Doesn't seem to be thread safe
- i changed some case with grow and the write speed is more quickly than others HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashmap.