Skip to content
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

threads deadlock in gc_gms_mark_and_sweep() #1187

Closed
rurban opened this issue Jan 22, 2015 · 1 comment
Closed

threads deadlock in gc_gms_mark_and_sweep() #1187

rurban opened this issue Jan 22, 2015 · 1 comment
Assignees
Milestone

Comments

@rurban
Copy link
Member

rurban commented Jan 22, 2015

With the new --optimized=-O3
./parrot examples/threads/chameneos.pbc hangs

$ gdb -p 32197 --args ./parrot examples/threads/chameneos.pbc

__lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
135 in ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
(gdb) bt
#0  __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1  0x00007f3b045e84b9 in _L_lock_909 () from /lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007f3b045e82e0 in __GI___pthread_mutex_lock (mutex=0xf48170) at ../nptl/pthread_mutex_lock.c:79
#3  0x00007f3b06fc83a4 in gc_gms_mark_and_sweep ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#4  0x00007f3b06fca66b in pool_allocate () from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#5  0x00007f3b06fc7aac in gc_gms_allocate_fixed_size_storage ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#6  0x00007f3b07044fba in ensure_positionals_storage_ap ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#7  0x00007f3b07045b90 in Parrot_CallContext_push_pmc ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#8  0x00007f3b06fcf0b6 in set_call_from_varargs ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#9  0x00007f3b06fd06f0 in Parrot_pcc_build_call_from_varargs ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#10 0x00007f3b06fc28ce in Parrot_ext_call ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#11 0x00007f3b0709a9b6 in Parrot_Task_invoke ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#12 0x00007f3b06fce48c in Parrot_pcc_invoke_from_sig_object ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#13 0x00007f3b06fc295f in Parrot_ext_call ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#14 0x00007f3b06fef3ed in Parrot_cx_outer_runloop ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#15 0x00007f3b06fef4e7 in Parrot_cx_begin_execution ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#16 0x00007f3b06ff7ddb in Parrot_pf_execute_bytecode_program ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#17 0x00007f3b06fbe8a8 in Parrot_api_run_bytecode ()
   from /home/rurban/Perl/p6/parrot-git/blib/lib/libparrot.so.7.0.0
#18 0x0000000000401f75 in main ()

we need to move the lock downwards to the guard

@rurban
Copy link
Member Author

rurban commented Jan 22, 2015

With -O3 -g after the changed LOCK, we only got our usual possible races:

$ tsan ./parrot examples/threads/chameneos.pbc
==21711== ThreadSanitizer, a data race detector
==21711== Copyright (C) 2008-2010, and GNU GPL'd, by Google Inc.
==21711== Using Valgrind-3.8.0.SVN and LibVEX; rerun with -h for copyright info
==21711== Command: ./parrot examples/threads/chameneos.pbc
==21711== 
==21711== ThreadSanitizerValgrind r4356: hybrid=no
==21711== INFO: Allocating 256Mb (32 * 8M) for Segments.
==21711== INFO: Will allocate up to 640Mb for 'previous' stack traces.
==21711== INFO: T0 is program's main thread
==21711== INFO: T2 has been created by T0. Use --announce-threads to see the creation stack.
==21711== WARNING: Possible data race during read of size 8 at 0x4223410: {{{
==21711==    T0 (L{}):
==21711==     #0  gc_gms_allocate_pmc_header /usr/src/parrot/parrot-git/src/gc/gc_gms.c:1526
==21711==     #1  Parrot_gc_new_pmc_header /usr/src/parrot/parrot-git/src/gc/api.c:314
==21711==     #2  Parrot_pmc_new /usr/src/parrot/parrot-git/src/pmc.c:572
==21711==     #3  Parrot_new_p_pc /usr/src/parrot/parrot-git/src/ops/core_ops.c:19660
==21711==     #4  runops_fast_core /usr/src/parrot/parrot-git/src/runcore/cores.c:495
==21711==     #5  runops_int /usr/src/parrot/parrot-git/src/runcore/main.c:220
==21711==     #6  runops /usr/src/parrot/parrot-git/src/call/ops.c:123
==21711==     #7  Parrot_pcc_invoke_from_sig_object /usr/src/parrot/parrot-git/src/call/pcc.c:307
==21711==     #8  Parrot_ext_call /usr/src/parrot/parrot-git/src/extend.c:164
==21711==     #9  Parrot_Task_invoke /usr/src/parrot/parrot-git/./src/pmc/task.pmc:175
==21711==     #10 Parrot_pcc_invoke_from_sig_object /usr/src/parrot/parrot-git/src/call/pcc.c:299
==21711==     #11 Parrot_ext_call /usr/src/parrot/parrot-git/src/extend.c:155
==21711==   Concurrent write(s) happened at (OR AFTER) these points:
==21711==    T2 (L{L12}):
==21711==     #0  gc_gms_allocate_pmc_attributes /usr/src/parrot/parrot-git/src/gc/gc_gms.c:1358
==21711==     #1  Parrot_pmc_new /usr/src/parrot/parrot-git/src/pmc.c:577
==21711==     #2  Parrot_Sub_clone /usr/src/parrot/parrot-git/./src/pmc/sub.pmc:542
==21711==     #3  Parrot_thread_create_local_sub /usr/src/parrot/parrot-git/src/thread.c:179
==21711==     #4  Parrot_thread_create_local_task /usr/src/parrot/parrot-git/src/thread.c:234
==21711==     #5  Parrot_ParrotInterpreter_nci_schedule_proxied /usr/src/parrot/parrot-git/./src/pmc/parrotinterpreter.pmc:712
==21711==     #6  Parrot_NativePCCMethod_invoke /usr/src/parrot/parrot-git/./src/pmc/nativepccmethod.pmc:119
==21711==     #7  runops_fast_core /usr/src/parrot/parrot-git/src/runcore/cores.c:495
==21711==     #8  runops_int /usr/src/parrot/parrot-git/src/runcore/main.c:220
==21711==     #9  runops /usr/src/parrot/parrot-git/src/call/ops.c:123
==21711==   Location 0x4223410 is 432 bytes inside a block starting at 0x4223260 of size 456 allocated by T0 from heap:
==21711==     #0  calloc /mnt/data/build/slave/full_linux_build/build/tsan/ts_valgrind_intercepts.c:444
==21711==     #1  mem_sys_allocate_zeroed /usr/src/parrot/parrot-git/src/gc/alloc_memory.c:102
==21711==     #2  Parrot_interp_allocate_interpreter /usr/src/parrot/parrot-git/src/interp/api.c:228
==21711==     #3  Parrot_api_make_interpreter /usr/src/parrot/parrot-git/src/embed/api.c:131
==21711==     #4  main /usr/src/parrot/parrot-git/frontend/parrot2/main.c:147
==21711==   Locks involved in this report (reporting last lock sites): {L12}
==21711==    L12 (0x4343170)
==21711==     #0  pthread_mutex_lock /mnt/data/build/slave/full_linux_build/build/tsan/ts_valgrind_intercepts.c:935
==21711==     #1  gc_gms_unblock_GC_mark_locked /usr/src/parrot/parrot-git/src/gc/gc_gms.c:1940
==21711==     #2  Parrot_NativePCCMethod_invoke /usr/src/parrot/parrot-git/./src/pmc/nativepccmethod.pmc:119
==21711==     #3  runops_fast_core /usr/src/parrot/parrot-git/src/runcore/cores.c:495
==21711==     #4  runops_int /usr/src/parrot/parrot-git/src/runcore/main.c:220
==21711==     #5  runops /usr/src/parrot/parrot-git/src/call/ops.c:123
==21711==     #6  Parrot_pcc_invoke_from_sig_object /usr/src/parrot/parrot-git/src/call/pcc.c:307
==21711==     #7  Parrot_ext_call /usr/src/parrot/parrot-git/src/extend.c:164
==21711==     #8  Parrot_Task_invoke /usr/src/parrot/parrot-git/./src/pmc/task.pmc:175
==21711==     #9  Parrot_pcc_invoke_from_sig_object /usr/src/parrot/parrot-git/src/call/pcc.c:299
==21711==     #10 Parrot_ext_call /usr/src/parrot/parrot-git/src/extend.c:155
==21711==     #11 Parrot_thread_outer_runloop /usr/src/parrot/parrot-git/src/thread.c:322
==21711==    Race verifier data: 0x4ED8BFC,0x4ED769C
==21711== }}}
going to sleep
==21711== INFO: T1 has been created by T0. Use --announce-threads to see the creation stack.
==21711== WARNING: Possible data race during read of size 8 at 0x529B6D8: {{{
==21711==    T0 (L{}):
==21711==     #0  Parrot_alarm_check /usr/src/parrot/parrot-git/src/alarm.c:158
==21711==     #1  Parrot_cx_check_scheduler /usr/src/parrot/parrot-git/src/scheduler.c:253
==21711==     #2  Parrot_branch_ic /usr/src/parrot/parrot-git/src/ops/core_ops.c:13736
==21711==     #3  runops_fast_core /usr/src/parrot/parrot-git/src/runcore/cores.c:495
==21711==     #4  runops_int /usr/src/parrot/parrot-git/src/runcore/main.c:220
==21711==     #5  runops /usr/src/parrot/parrot-git/src/call/ops.c:123
==21711==     #6  Parrot_pcc_invoke_from_sig_object /usr/src/parrot/parrot-git/src/call/pcc.c:307
==21711==     #7  Parrot_ext_call /usr/src/parrot/parrot-git/src/extend.c:164
==21711==     #8  Parrot_Task_invoke /usr/src/parrot/parrot-git/./src/pmc/task.pmc:175
==21711==     #9  Parrot_pcc_invoke_from_sig_object /usr/src/parrot/parrot-git/src/call/pcc.c:299
==21711==     #10 Parrot_ext_call /usr/src/parrot/parrot-git/src/extend.c:155
==21711==     #11 Parrot_cx_outer_runloop /usr/src/parrot/parrot-git/src/scheduler.c:149
==21711==   Concurrent write(s) happened at (OR AFTER) these points:
==21711==    T1 (L{L3}):
==21711==     #0  Parrot_alarm_runloop /usr/src/parrot/parrot-git/src/alarm.c:129
==21711==   Address 0x529B6D8 is 0 bytes inside data symbol "alarm_serial"
==21711==   Locks involved in this report (reporting last lock sites): {L3}
==21711==    L3 (0x529B6A0)
==21711==     #0  pthread_mutex_lock /mnt/data/build/slave/full_linux_build/build/tsan/ts_valgrind_intercepts.c:935
==21711==     #1  Parrot_alarm_runloop /usr/src/parrot/parrot-git/src/alarm.c:86
==21711==    Race verifier data: 0x4ED2B50,0x4ED2AC3
==21711== }}}
==21711== INFO: T4 has been created by T0. Use --announce-threads to see the creation stack.
==21711== WARNING: Possible data race during read of size 8 at 0x42FAB98: {{{
==21711==    T4 (L{}):
==21711==     #0  Parrot_Scheduler_unshift_pmc /usr/src/parrot/parrot-git/./src/pmc/scheduler.pmc:152
==21711==     #1  Parrot_cx_schedule_immediate /usr/src/parrot/parrot-git/src/scheduler.c:525
==21711==     #2  Parrot_ParrotInterpreter_nci_schedule_proxied /usr/src/parrot/parrot-git/./src/pmc/parrotinterpreter.pmc:712
==21711==     #3  Parrot_NativePCCMethod_invoke /usr/src/parrot/parrot-git/./src/pmc/nativepccmethod.pmc:119
==21711==     #4  runops_fast_core /usr/src/parrot/parrot-git/src/runcore/cores.c:495
==21711==     #5  runops_int /usr/src/parrot/parrot-git/src/runcore/main.c:220
==21711==     #6  runops /usr/src/parrot/parrot-git/src/call/ops.c:123
==21711==     #7  Parrot_pcc_invoke_from_sig_object /usr/src/parrot/parrot-git/src/call/pcc.c:307
==21711==     #8  Parrot_ext_call /usr/src/parrot/parrot-git/src/extend.c:164
==21711==     #9  Parrot_Task_invoke /usr/src/parrot/parrot-git/./src/pmc/task.pmc:175
==21711==     #10 Parrot_pcc_invoke_from_sig_object /usr/src/parrot/parrot-git/src/call/pcc.c:299
==21711==     #11 Parrot_ext_call /usr/src/parrot/parrot-git/src/extend.c:155
==21711==   Concurrent write(s) happened at (OR AFTER) these points:
==21711==    T0 (L{}):
==21711==     #0  Parrot_cx_next_task /usr/src/parrot/parrot-git/src/scheduler.c:717
==21711==     #1  Parrot_cx_outer_runloop /usr/src/parrot/parrot-git/src/scheduler.c:149
==21711==     #2  Parrot_cx_begin_execution /usr/src/parrot/parrot-git/src/scheduler.c:109
==21711==     #3  Parrot_pf_execute_bytecode_program /usr/src/parrot/parrot-git/src/packfile/api.c:2905
==21711==     #4  Parrot_api_run_bytecode /usr/src/parrot/parrot-git/src/embed/bytecode.c:161
==21711==     #5  main /usr/src/parrot/parrot-git/frontend/parrot2/main.c:190
==21711==   Location 0x42FAB98 is 1384 bytes inside a block starting at 0x42FA630 of size 4096 allocated by T0 from heap:
==21711==     #0  calloc /mnt/data/build/slave/full_linux_build/build/tsan/ts_valgrind_intercepts.c:444
==21711==     #1  mem_sys_allocate_zeroed /usr/src/parrot/parrot-git/src/gc/alloc_memory.c:102
==21711==     #2  allocate_new_pool_arena /usr/src/parrot/parrot-git/src/gc/fixed_allocator.c:543
==21711==     #3  Parrot_gc_pool_allocate /usr/src/parrot/parrot-git/src/gc/fixed_allocator.c:444
==21711==     #4  gc_gms_allocate_pmc_header /usr/src/parrot/parrot-git/src/gc/gc_gms.c:1551
==21711==     #5  Parrot_gc_new_pmc_header /usr/src/parrot/parrot-git/src/gc/api.c:314
==21711==     #6  Parrot_pmc_new /usr/src/parrot/parrot-git/src/pmc.c:572
==21711==     #7  Parrot_nci_load_extra_thunks /usr/src/parrot/parrot-git/src/nci/extra_thunks.c:4735
==21711==     #8  init_world /usr/src/parrot/parrot-git/src/global_setup.c:226
==21711==     #9  Parrot_interp_initialize_interpreter /usr/src/parrot/parrot-git/src/interp/api.c:291
==21711==    Race verifier data: 0x4FAF62F,0x4F02C00
==21711== }}}
==21711== WARNING: Possible data race during read of size 8 at 0x432EF60: {{{
==21711==    T2 (L{}):
==21711==     #0  Parrot_Scheduler_shift_pmc /usr/src/parrot/parrot-git/./src/pmc/scheduler.pmc:172
==21711==     #1  Parrot_cx_next_task /usr/src/parrot/parrot-git/src/scheduler.c:216
==21711==     #2  Parrot_thread_outer_runloop /usr/src/parrot/parrot-git/src/thread.c:322
==21711==   Concurrent write(s) happened at (OR AFTER) these points:
==21711==    T0 (L{L76}):
==21711==     #0  Parrot_cx_schedule_immediate /usr/src/parrot/parrot-git/src/scheduler.c:526
==21711==     #1  Parrot_Task_invoke /usr/src/parrot/parrot-git/./src/pmc/task.pmc:215
==21711==     #2  Parrot_pcc_invoke_from_sig_object /usr/src/parrot/parrot-git/src/call/pcc.c:299
==21711==     #3  Parrot_ext_call /usr/src/parrot/parrot-git/src/extend.c:155
==21711==     #4  Parrot_cx_outer_runloop /usr/src/parrot/parrot-git/src/scheduler.c:149
==21711==     #5  Parrot_cx_begin_execution /usr/src/parrot/parrot-git/src/scheduler.c:109
==21711==     #6  Parrot_pf_execute_bytecode_program /usr/src/parrot/parrot-git/src/packfile/api.c:2905
==21711==     #7  Parrot_api_run_bytecode /usr/src/parrot/parrot-git/src/embed/bytecode.c:161
==21711==     #8  main /usr/src/parrot/parrot-git/frontend/parrot2/main.c:190
==21711==   Location 0x432EF60 is 64 bytes inside a block starting at 0x432EF20 of size 4096 allocated by T0 from heap:
==21711==     #0  calloc /mnt/data/build/slave/full_linux_build/build/tsan/ts_valgrind_intercepts.c:444
==21711==     #1  mem_sys_allocate_zeroed /usr/src/parrot/parrot-git/src/gc/alloc_memory.c:102
==21711==     #2  allocate_new_pool_arena /usr/src/parrot/parrot-git/src/gc/fixed_allocator.c:543
==21711==     #3  Parrot_gc_pool_allocate /usr/src/parrot/parrot-git/src/gc/fixed_allocator.c:444
==21711==     #4  gc_gms_allocate_pmc_header /usr/src/parrot/parrot-git/src/gc/gc_gms.c:1551
==21711==     #5  Parrot_gc_new_pmc_header /usr/src/parrot/parrot-git/src/gc/api.c:314
==21711==     #6  Parrot_pmc_new_init /usr/src/parrot/parrot-git/src/pmc.c:572
==21711==     #7  Parrot_thread_create_proxy /usr/src/parrot/parrot-git/src/thread.c:156
==21711==     #8  Parrot_interp_clone /usr/src/parrot/parrot-git/src/interp/api.c:422
==21711==     #9  Parrot_thread_create /usr/src/parrot/parrot-git/src/thread.c:76
==21711==   Locks involved in this report (reporting last lock sites): {L76}
==21711==    L76 (0x4343FB8)
==21711==     #0  pthread_mutex_lock /mnt/data/build/slave/full_linux_build/build/tsan/ts_valgrind_intercepts.c:935
==21711==     #1  Parrot_Task_invoke /usr/src/parrot/parrot-git/./src/pmc/task.pmc:204
==21711==     #2  Parrot_pcc_invoke_from_sig_object /usr/src/parrot/parrot-git/src/call/pcc.c:299
==21711==     #3  Parrot_ext_call /usr/src/parrot/parrot-git/src/extend.c:155
==21711==     #4  Parrot_cx_outer_runloop /usr/src/parrot/parrot-git/src/scheduler.c:149
==21711==     #5  Parrot_cx_begin_execution /usr/src/parrot/parrot-git/src/scheduler.c:109
==21711==     #6  Parrot_pf_execute_bytecode_program /usr/src/parrot/parrot-git/src/packfile/api.c:2905
==21711==     #7  Parrot_api_run_bytecode /usr/src/parrot/parrot-git/src/embed/bytecode.c:161
==21711==     #8  main /usr/src/parrot/parrot-git/frontend/parrot2/main.c:190
==21711==    Race verifier data: 0x4FAF6EE,0x4F03031
==21711== }}}
woke up just in time for exit
2
==21711== 
==21711== ThreadSanitizer summary: reported 4 warning(s) (4 race(s))

rurban pushed a commit that referenced this issue Jan 22, 2015
move the lock downwards to the guard. Fixes GH #1187
rurban pushed a commit that referenced this issue Jan 22, 2015
move the lock downwards to the guard. Fixes GH #1187
rurban pushed a commit that referenced this issue Jan 22, 2015
move the lock downwards to the guard. Fixes GH #1187
@rurban rurban added this to the 7.0.1 milestone Jan 22, 2015
@rurban rurban closed this as completed Jan 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant