• Ken Rockot's avatar
    [mojo] Don't inline unions with string fields · 2b0e1284
    Ken Rockot authored
    Inline allocations for unions have been allowed as long as the union
    doesn't contain any non-string reference-type fields (i.e. non-handle,
    non-POD fields). Exceptions were made for strings since they're copyable
    and don't introduce a possibility of recursive types.
    
    InlinedStructPtr however is incompatible with a union's generated
    wrapper class when the union's first field is a reference type like a
    string. This results in difficult to diagnose crashes in cases that are
    meant to be allowed by the bindings.
    
    This change prohibits unions from being allocated inline unless they
    contain only POD fields.
    
    Inline allocations could be allowed in these (and other) cases, but
    that would require more fundamental refactoring of the wrapper types
    and/or StructPtr/InlinedStructPtr.
    
    Fixed: 1114366
    Change-Id: I623779f067e777a9240aef67a40decc884948247
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2347167Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
    Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
    Commit-Queue: Daniel Cheng <dcheng@chromium.org>
    Auto-Submit: Ken Rockot <rockot@google.com>
    Cr-Commit-Position: refs/heads/master@{#796660}
    2b0e1284
test_unions.mojom 2.36 KB