• Nico Weber's avatar
    mac: Fix out-of-bounds access in GetAlteredLibraryData. · 9969257b
    Nico Weber authored
    With a chance of 1/256, we'd read past the end of kValidLiteralValues.
    In practice, that read would return zeroes, which we'd write to
    kTestLibData -- but zeroes aren't valid literal values, so that would
    then make TestShader() crash when it tried to link the program.
    
    Not sure if this is related to crbug.com/1051923, but it's in the
    same area at least.
    
    Add a components/metal_util:unit_tests target. Covering code is useful
    even if the test doesn't verify a lot, because then the ASan bots can
    find stuff like this for us. (...but in this case, asan doesn't find
    the out-of-bounds read because we build with `-asan-globals=0` on
    macOS because of https://crbug.com/352073 .
    But the test also checks for non-0 and runs the code often enough
    that the test consistently fails before the fix and consistently passes
    with it.)
    
    Drive-by no-op cleanups while here:
    - Remove EXPORTs on enums, they don't have any effect
    - Remove redundant is_ios block in components/BUILD.gn
    
    Bug: 1147027,1051923,1085899
    Cq-Include-Trybots: luci.chromium.try:mac_chromium_asan_rel_ng
    Change-Id: Ia7f9735e450c70eb64b826a499dc60690714112e
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526161
    Auto-Submit: Nico Weber <thakis@chromium.org>
    Reviewed-by: default avatarccameron <ccameron@chromium.org>
    Commit-Queue: Nico Weber <thakis@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#825730}
    9969257b
test_shader.mm 55.5 KB