Prevent re-entrant calls to SampleAndCompareGamepadState.

SampleAndCompareGamepadState uses a base::AutoReset construct to ensure
that no re-entrant calls were allowed; however, this was mistakenly
being created as a temporary object, which essentially means that the
flag that guards against re-entrant calls was never set.  The fix is to
actually create an object, so that the expected scoped lifetime applies.

This code path seems to only surface when two controllers are set to
disconnected at the same time, as this nulls out the controllers.
Once the event to dispatch the first controller is sent, if the event
handler queries the state, it will make a re-entrant call to
SampleAndCompareGamepad state; since no state has changed, it will exit
relatively quickly, but will call SampleGamepads which then modifies
gamepads_back_ to set both newly disconnected controllers to null. When
control returns after firing this event, and continues through the list,
the next controller (which the code does not expect to be null), has
been nulled out by the re-entrant call, thus causing the DCHECK/AV.

Bug: 963416
Change-Id: Ia46b27af47b5df4723af677bc8a1b303a6e7152a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1621427
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Matt Reynolds <mattreynolds@chromium.org>
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#661584}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: c0e3b948a143e087074cf1216ffd72a3dcc9a4be
1 file changed
tree: f4693c7a69cc1dde4f8eb52561e770c5b84bbbc8
  1. abseil-cpp/
  2. accessibility-audit/
  3. accessibility_test_framework/
  4. adobe/
  5. afl/
  6. android_build_tools/
  7. android_crazy_linker/
  8. android_data_chart/
  9. android_deps/
  10. android_media/
  11. android_opengl/
  12. android_platform/
  13. android_protobuf/
  14. android_sdk/
  15. android_support_test_runner/
  16. android_swipe_refresh/
  17. android_system_sdk/
  18. apache-mac/
  19. apache-portable-runtime/
  20. apache-win32/
  21. apk-patch-size-estimator/
  22. apple_apsl/
  23. arcore-android-sdk/
  24. ashmem/
  25. auto/
  26. axe-core/
  27. bazel/
  28. binutils/
  29. blanketjs/
  30. blink/
  31. boringssl/
  32. bouncycastle/
  33. breakpad/
  34. brotli/
  35. bspatch/
  36. byte_buddy/
  37. cacheinvalidation/
  38. cct_dynamic_module/
  39. ced/
  40. chaijs/
  41. checkstyle/
  42. chromevox/
  43. cld_3/
  44. closure_compiler/
  45. colorama/
  46. crashpad/
  47. crc32c/
  48. custom_tabs_client/
  49. d3/
  50. dav1d/
  51. decklink/
  52. devscripts/
  53. dom_distiller_js/
  54. emoji-segmenter/
  55. errorprone/
  56. espresso/
  57. expat/
  58. feed/
  59. flatbuffers/
  60. flot/
  61. fontconfig/
  62. freetype/
  63. fuchsia-sdk/
  64. gestures/
  65. gif_player/
  66. glfw/
  67. glslang/
  68. google-truth/
  69. google_android_play_core/
  70. google_appengine_cloudstorage/
  71. google_input_tools/
  72. google_toolbox_for_mac/
  73. google_trust_services/
  74. googletest/
  75. gradle_wrapper/
  76. grpc/
  77. gson/
  78. guava/
  79. gvr-android-keyboard/
  80. gvr-android-sdk/
  81. hamcrest/
  82. harfbuzz-ng/
  83. hunspell/
  84. iaccessible2/
  85. iccjpeg/
  86. icu4j/
  87. ijar/
  88. ink/
  89. inspector_protocol/
  90. instrumented_libraries/
  91. intellij/
  92. isimpledom/
  93. jacoco/
  94. jinja2/
  95. jsoncpp/
  96. jsr-305/
  97. jstemplate/
  98. junit/
  99. khronos/
  100. lcov/
  101. leveldatabase/
  102. libaddressinput/
  103. libaom/
  104. libcxx-pretty-printers/
  105. libdrm/
  106. libevdev/
  107. libFuzzer/
  108. libjingle_xmpp/
  109. libjpeg/
  110. liblouis/
  111. libovr/
  112. libphonenumber/
  113. libpng/
  114. libprotobuf-mutator/
  115. libsecret/
  116. libsync/
  117. libudev/
  118. libusb/
  119. libvpx/
  120. libwebm/
  121. libwebp/
  122. libxml/
  123. libXNVCtrl/
  124. libxslt/
  125. logilab/
  126. lzma_sdk/
  127. mach_override/
  128. markdown/
  129. markupsafe/
  130. material_design_icons/
  131. mesa_headers/
  132. metrics_proto/
  133. microsoft_webauthn/
  134. minigbm/
  135. minizip/
  136. mocha/
  137. mockito/
  138. modp_b64/
  139. motemplate/
  140. mozilla/
  141. netty-tcnative/
  142. netty4/
  143. node/
  144. nvml/
  145. objenesis/
  146. ocmock/
  147. openh264/
  148. openscreen/
  149. openvr/
  150. opus/
  151. ots/
  152. ow2_asm/
  153. pexpect/
  154. pffft/
  155. ply/
  156. polymer/
  157. proguard/
  158. protobuf/
  159. protoc_javalite/
  160. pycoverage/
  161. pyjson5/
  162. pylint/
  163. pymock/
  164. pystache/
  165. Python-Markdown/
  166. pywebsocket/
  167. qcms/
  168. quic_trace/
  169. qunit/
  170. r8/
  171. re2/
  172. requests/
  173. rnnoise/
  174. robolectric/
  175. s2cellid/
  176. sfntly/
  177. shaderc/
  178. simplejson/
  179. sinonjs/
  180. smhasher/
  181. snappy/
  182. speech-dispatcher/
  183. spirv-cross/
  184. spirv-headers/
  185. SPIRV-Tools/
  186. sqlite/
  187. sqlite4java/
  188. sudden_motion_sensor/
  189. tcmalloc/
  190. test_fonts/
  191. tlslite/
  192. ub-uiautomator/
  193. unrar/
  194. usb_ids/
  195. usrsctp/
  196. v4l-utils/
  197. vulkan/
  198. wayland/
  199. wayland-protocols/
  200. wds/
  201. web-animations-js/
  202. webdriver/
  203. webgl/
  204. webrtc_overrides/
  205. webxr_test_pages/
  206. widevine/
  207. win_build_output/
  208. woff2/
  209. wtl/
  210. xstream/
  211. yasm/
  212. zlib/
  213. .gitignore
  214. BUILD.gn
  215. DEPS
  216. libjpeg.gni
  217. OWNERS
  218. PRESUBMIT.py
  219. README.chromium
  220. README.chromium.template