Read thread-local mark-stack inside critical section

Reading thread-local mark-stack outside mark_stack_lock_'s critical
section (CS) and then adding it to pooled_mark_stacks_ vector in the CS
leads to concurrency issue. A destroying mutator reads its mark-stack
and then waits on mark_stack_lock_ as concurrently running GC-thread
revokes the mutator's mark-stack. Eventually, when mutator resumes, it
adds the same mark-stack again to the pooled_mark_stacks_ vector.

Therefore, reading the thread-local mark-stack should also be performed
inside the mark_stack_lock_'s CS.

Test: art/test/testrunner/testrunner.py
Bug: 140119552
Change-Id: I1daf7131e380699cd6bfcc8bfe2f2db52b661bd6
2 files changed