[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
Showing
- garnet/go/src/fidl/compiler/backend/goldens/doc_comments.test.fidl.json.llcpp.cc.golden 19 additions, 2 deletions...ckend/goldens/doc_comments.test.fidl.json.llcpp.cc.golden
- garnet/go/src/fidl/compiler/backend/goldens/doc_comments.test.fidl.json.llcpp.h.golden 5 additions, 7 deletions...ackend/goldens/doc_comments.test.fidl.json.llcpp.h.golden
- garnet/go/src/fidl/compiler/backend/goldens/protocols.test.fidl.json.llcpp.cc.golden 62 additions, 4 deletions.../backend/goldens/protocols.test.fidl.json.llcpp.cc.golden
- garnet/go/src/fidl/compiler/backend/goldens/protocols.test.fidl.json.llcpp.h.golden 12 additions, 28 deletions...r/backend/goldens/protocols.test.fidl.json.llcpp.h.golden
- garnet/go/src/fidl/compiler/backend/goldens/union.test.fidl.json.llcpp.cc.golden 43 additions, 2 deletions...iler/backend/goldens/union.test.fidl.json.llcpp.cc.golden
- garnet/go/src/fidl/compiler/backend/goldens/union.test.fidl.json.llcpp.h.golden 7 additions, 21 deletions...piler/backend/goldens/union.test.fidl.json.llcpp.h.golden
- garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/union.tmpl.go 34 additions, 10 deletions.../compiler/llcpp_backend/templates/fragments/union.tmpl.go
- garnet/public/lib/fidl/llcpp/union_test.cc 41 additions, 0 deletionsgarnet/public/lib/fidl/llcpp/union_test.cc
- zircon/system/fidl/fuchsia-io/gen/llcpp/fidl.cc 91 additions, 2 deletionszircon/system/fidl/fuchsia-io/gen/llcpp/fidl.cc
- zircon/system/fidl/fuchsia-io/gen/llcpp/include/fuchsia/io/llcpp/fidl.h 11 additions, 49 deletions...fidl/fuchsia-io/gen/llcpp/include/fuchsia/io/llcpp/fidl.h
- zircon/system/utest/fidl-llcpp-interop/generated/fidl_llcpp_basictypes.cc 31 additions, 2 deletions...est/fidl-llcpp-interop/generated/fidl_llcpp_basictypes.cc
- zircon/system/utest/fidl-llcpp-interop/generated/fidl_llcpp_basictypes.h 6 additions, 14 deletions...test/fidl-llcpp-interop/generated/fidl_llcpp_basictypes.h
- zircon/system/utest/fidl-llcpp-interop/generated/fidl_llcpp_dirent.h 2 additions, 2 deletions...em/utest/fidl-llcpp-interop/generated/fidl_llcpp_dirent.h
Loading
Please register or sign in to comment