Skip to content
Snippets Groups Projects
Commit 370d15d2 authored by Yifei Teng's avatar Yifei Teng Committed by CQ bot account: commit-bot@chromium.org
Browse files

[fidl] [llcpp] Fix an undefined behavior in move constructor of unions

A subtle case in the move constructor of llcpp unions was exposed in the
fdio refactor, when the code uses more than two std::moves, and compiled
by GCC for ARM64. The move constructor delegates the move of the union
payload to the corresponding move assignment operator of the payload.
However, the payload's memory is not initilized when its move assignment
operator is invoked, causing potential undefined behaivor.

GCC perhaps took advantage of this and generated unexpected code.

TEST: https://fuchsia-review.googlesource.com/c/fuchsia/+/274654 passes
all the tests, when rebased over this patch. I'm not exactly sure how to
write a test for this exact case.

Change-Id: I05b1eb4be60d921a7ab12f167b45189ab1c4de94
parent 4824de96
No related branches found
No related tags found
Loading
Showing
with 364 additions and 143 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment