OSDN Git Service

Fix locking on string init map (again).
authorVladimir Marko <vmarko@google.com>
Mon, 21 Sep 2015 11:00:16 +0000 (12:00 +0100)
committerVladimir Marko <vmarko@google.com>
Mon, 21 Sep 2015 12:24:18 +0000 (13:24 +0100)
commit78568351b22554c3a885216cd5be480dab88a951
tree0f4a41dfd93535e0f3165ea94b302a5cc36cbfd1
parent47d89c7376090a3a4b8eb114e2c861afe27d01d0
Fix locking on string init map (again).

Follow-up to
    https://android-review.googlesource.com/172036 ,
    https://android-review.googlesource.com/171621 .

Don't overwrite existing values, only insert new ones.
(Also improve performance by using move semantics.)

This prevents the following race: Thread 1 looks for string
init map for a method but doesn't find it, so it starts to
construct a new map. Thread 2 is doing the same but it's
faster and actually inserts the new map and keeps a pointer
to it. After Thread 2 releases the lock, Thread 1 acquires
it and starts to Overwrite() the element that the Thread 2
is currently using, so Thread 2 ends up looking at a map
that's being actively modified.

Change-Id: I135571af644363ea7bb282969a1bc7287b34f9b2
runtime/interpreter/interpreter_common.cc
runtime/safe_map.h
runtime/verifier/method_verifier.cc