lock-free
lock-free copied to clipboard
concurrency bug? hang / assertion error.
I copied the lock-free-0.1.2/lock-free/src/lock_free/dlist.d to local, and run the last unittest as main:
$ diff ........../.dub/packages/lock-free-0.1.2/lock-free/src/lock_free/dlist.d .
1c1,3
< module lock_free.dlist;
---
> /+dub.sdl:
> +/
> //module lock_free.dlist;
551c553
< version (unittest):
---
> //version (unittest):
602,603c604,605
< alias shared AtomicDList!(TPayload) TList;
< //alias SyncedDList!(TPayload) TList;
---
> //alias shared AtomicDList!(TPayload) TList;
> alias SyncedDList!(TPayload) TList;
605c607
< enum amount = 10_000;
---
> int amount = 100;
715c717,718
< unittest
---
> // unittest
> void main()
change to use SyncedDList, and int amount = 100; the program will hang, I have to Ctrl-C to kill it.
$ time /tmp/.dub/build/dlist-~master/application-debug-linux.posix-x86_64-dmd_2092-E2A9C5AF8650438037BBDF8239D7083C/dlist
size 35
size 1
size 27
size 35
queue empty? -> 0
size 49
size 49
size 201
size 1
^C
^C
real 29m16.360s
user 0m1.061s
sys 0m0.140s
$ file /tmp/.dub/build/dlist-~master/application-debug-linux.posix-x86_64-dmd_2092-E2A9C5AF8650438037BBDF8239D7083C/dlist
/tmp/.dub/build/dlist-~master/application-debug-linux.posix-x86_64-dmd_2092-E2A9C5AF8650438037BBDF8239D7083C/dlist: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=89d92565a021c0966ee3e5b981ab22d808f24ec9, with debug_info, not stripped
I tried set int amount = 10; it still hang.
With LDC, this sometimes also hang, sometimes I got assertion error:
$ /tmp/.dub/build/dlist-~master/application-debug-linux.posix-x86_64-ldc_2091-90F71C0B6688A767CE6B8CC3061B6ABD/dlist
size 1
size 1
size 1
size 1
queue empty? -> 0
size 1
size 1
size 4
size 11
list empty? -> 0
size 11
size 11
size 1
size 1
size 1
size 1
size 8
size 3
mixed empty? -> 2
[email protected](811): 2
----------------
??:? [0x559eaccb2875]
??:? [0x559eaccbe0b2]
??:? [0x559eacca306d]
??:? [0x559eacc9ae09]
dlist.d:811 [0x559eacc66235]
??:? [0x559eacca2d3b]
??:? [0x559eacca2c32]
??:? [0x559eacca2a8d]
/home/zhou/project/ldc2-1.21.0-linux-x86_64/bin/../import/core/internal/entrypoint.d:42 [0x559eacc679b4]
??:? __libc_start_main [0x7f2e909efb96]
??:? [0x559eacc65c69]
$ file /tmp/.dub/build/dlist-~master/application-debug-linux.posix-x86_64-ldc_2091-90F71C0B6688A767CE6B8CC3061B6ABD/dlist
/tmp/.dub/build/dlist-~master/application-debug-linux.posix-x86_64-ldc_2091-90F71C0B6688A767CE6B8CC3061B6ABD/dlist: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=c83cacffae284cfd2e7ce1e74d42d7d422b1423a, with debug_info, not stripped
I tested AtomicDList as well, didn't have assertion error, but it hang sometimes (with LDC).