New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deadlock when using Iterator #29
Comments
I haven't checked your example, but what happens if you enable the lock around erase()? Does the deadlock go away? |
If I enable the lock around erase, the deadlock is still there. It doesn't happen every time but it happens sometimes (usually within a few seconds). Please play with the example (the attached project is ready to build, just run make), there's something wrong there and it deadlocks in multiple configurations. In my real-world application it was locking after few hours of heavy work in 8 threads and the problem went away when I replaced junction with another concurrent hash map |
Hi Adrian, The problem is that you are manipulating entries using the Null key (0). Looks like I didn't mention this important detail in the README, only the blog post. If you build and run your sample with TURF_WITH_ASSERTS=1 (as the CMake-based projects do in the Debug/RelWithAsserts configurations) you will hit an assert pointing this out. When I change Thanks for raising the possible issue nonetheless. Given that you are forced to use a mutex due to Junction's current restriction on using iterators, I'd actually suggest sticking with another concurrent map that doesn't have that restriction! |
I found out that this example deadlocks in insert():
After running this deadlocks in junction/details/Leapfrog.h:235:
If I remove case 2: from the example, there is no deadlock, so it appears that the iterator is causing some race condition. I used mutex on insert and iterator since comment for Iterator says
In my case I insert and erase values very frequently from different threads, but occasionally I need to be able to iterate through all items (and inserts and erases may happen and that time too, hence the mutex).
Could you investigate and see if this is a bug in Junction or my mistake?
I'm attaching my complete example with makefile: junction-deadlock.zip
The text was updated successfully, but these errors were encountered: