diff --git a/.github/workflows/test_upb.yml b/.github/workflows/test_upb.yml index 813a520ff3..e819c377c3 100644 --- a/.github/workflows/test_upb.yml +++ b/.github/workflows/test_upb.yml @@ -20,6 +20,7 @@ jobs: - { name: "Fastbuild" } - { name: "Optimized", flags: "-c opt" } - { name: "FastTable", flags: "--//upb:fasttable_enabled=true" } + - { name: "FastTable ASAN", flags: "--//upb:fasttable_enabled=true --config=asan", exclude-targets: "-//benchmarks:benchmark -//python/..." } - { name: "ASAN", flags: "--config=asan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/..." } - { name: "UBSAN", flags: "--config=ubsan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/... -//lua/..." } - { name: "32-bit", flags: "--copt=-m32 --linkopt=-m32", exclude-targets: "-//benchmarks:benchmark -//python/..." } diff --git a/src/google/protobuf/editions/BUILD b/src/google/protobuf/editions/BUILD index cba63638a0..e22c9acf53 100644 --- a/src/google/protobuf/editions/BUILD +++ b/src/google/protobuf/editions/BUILD @@ -1,4 +1,5 @@ load("@rules_python//python:proto.bzl", "py_proto_library") +load("//bazel:upb_proto_library.bzl", "upb_c_proto_library", "upb_proto_reflection_library") load("@rules_cc//cc:defs.bzl", "cc_proto_library") load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load(":defaults.bzl", "compile_edition_defaults", "embed_edition_defaults") @@ -106,6 +107,19 @@ py_proto_library( deps = [":test_messages_proto2_editions_proto"], ) +upb_c_proto_library( + name = "test_messages_proto2_editions_upb_proto", + testonly = 1, + deps = [":test_messages_proto2_editions_proto"], +) + +upb_proto_reflection_library( + name = "test_messages_proto2_editions_upbdefs", + testonly = 1, + visibility = ["//upb/conformance:__pkg__"], + deps = [":test_messages_proto2_editions_proto"], +) + proto_library( name = "test_messages_proto3_editions_proto", testonly = True, @@ -135,6 +149,19 @@ py_proto_library( deps = [":test_messages_proto3_editions_proto"], ) +upb_c_proto_library( + name = "test_messages_proto3_editions_upb_proto", + testonly = 1, + deps = [":test_messages_proto3_editions_proto"], +) + +upb_proto_reflection_library( + name = "test_messages_proto3_editions_upbdefs", + testonly = 1, + visibility = ["//upb/conformance:__pkg__"], + deps = ["test_messages_proto3_editions_proto"], +) + # Export these for conformance tests until we support py_proto_library. exports_files( [ diff --git a/upb/conformance/BUILD b/upb/conformance/BUILD index 18cfc57c14..94d18bac3a 100644 --- a/upb/conformance/BUILD +++ b/upb/conformance/BUILD @@ -73,6 +73,8 @@ cc_binary( ":conformance_upb_proto_reflection", ":test_messages_proto2_upbdefs", ":test_messages_proto3_upbdefs", + "//src/google/protobuf/editions:test_messages_proto2_editions_upbdefs", + "//src/google/protobuf/editions:test_messages_proto3_editions_upbdefs", "//upb:json", "//upb:port", "//upb:reflection", @@ -84,7 +86,7 @@ cc_binary( make_shell_script( name = "gen_test_conformance_upb", out = "test_conformance_upb.sh", - contents = "$1 --enforce_recommended --failure_list $2 $3", + contents = "$1 --maximum_edition 2023 --enforce_recommended --failure_list $2 $3", ) sh_test( @@ -124,6 +126,8 @@ cc_binary( ":conformance_upb_proto_reflection", ":test_messages_proto2_upbdefs", ":test_messages_proto3_upbdefs", + "//src/google/protobuf/editions:test_messages_proto2_editions_upbdefs", + "//src/google/protobuf/editions:test_messages_proto3_editions_upbdefs", "//upb:json", "//upb:port", "//upb:reflection", @@ -135,7 +139,7 @@ cc_binary( make_shell_script( name = "gen_test_conformance_upb_dynamic_minitable", out = "test_conformance_upb_dynamic_minitable.sh", - contents = "$1 --enforce_recommended --failure_list $2 $3", + contents = "$1 --maximum_edition 2023 --enforce_recommended --failure_list $2 $3", ) sh_test( diff --git a/upb/conformance/conformance_upb.c b/upb/conformance/conformance_upb.c index a91224bf35..4efe32c17d 100644 --- a/upb/conformance/conformance_upb.c +++ b/upb/conformance/conformance_upb.c @@ -16,6 +16,8 @@ #include "conformance/conformance.upb.h" #include "conformance/conformance.upbdefs.h" +#include "google/protobuf/editions/golden/test_messages_proto2_editions.upbdefs.h" +#include "google/protobuf/editions/golden/test_messages_proto3_editions.upbdefs.h" #include "google/protobuf/test_messages_proto2.upbdefs.h" #include "google/protobuf/test_messages_proto3.upbdefs.h" #include "upb/json/decode.h" @@ -309,9 +311,19 @@ int main(void) { symtab, &google_protobuf_test_messages_proto2_proto_upbdefinit, true); _upb_DefPool_LoadDefInitEx( symtab, &google_protobuf_test_messages_proto3_proto_upbdefinit, true); + _upb_DefPool_LoadDefInitEx( + symtab, + &google_protobuf_editions_golden_test_messages_proto2_editions_proto_upbdefinit, + true); + _upb_DefPool_LoadDefInitEx( + symtab, + &google_protobuf_editions_golden_test_messages_proto3_editions_proto_upbdefinit, + true); #else protobuf_test_messages_proto2_TestAllTypesProto2_getmsgdef(symtab); + protobuf_test_messages_editions_proto2_TestAllTypesProto2_getmsgdef(symtab); protobuf_test_messages_proto3_TestAllTypesProto3_getmsgdef(symtab); + protobuf_test_messages_editions_proto3_TestAllTypesProto3_getmsgdef(symtab); #endif while (1) { diff --git a/upb/conformance/conformance_upb_failures.txt b/upb/conformance/conformance_upb_failures.txt index 2fb4dc881f..9b78753bdc 100644 --- a/upb/conformance/conformance_upb_failures.txt +++ b/upb/conformance/conformance_upb_failures.txt @@ -1,2 +1,4 @@ Recommended.Proto3.JsonInput.IgnoreUnknownEnumStringValueInMapValue.ProtobufOutput Recommended.Proto3.JsonInput.IgnoreUnknownEnumStringValueInRepeatedField.ProtobufOutput +Recommended.Editions_Proto3.JsonInput.IgnoreUnknownEnumStringValueInMapValue.ProtobufOutput +Recommended.Editions_Proto3.JsonInput.IgnoreUnknownEnumStringValueInRepeatedField.ProtobufOutput diff --git a/upb/wire/decode_fast.c b/upb/wire/decode_fast.c index 8e2860a76b..9efccd15ed 100644 --- a/upb/wire/decode_fast.c +++ b/upb/wire/decode_fast.c @@ -658,12 +658,14 @@ static const char* fastdecode_longstring_noutf8( UPB_FORCEINLINE static void fastdecode_docopy(upb_Decoder* d, const char* ptr, uint32_t size, - int copy, char* data, upb_StringView* dst) { + int copy, char* data, size_t data_offset, + upb_StringView* dst) { d->arena.head.ptr += copy; - dst->data = data; + dst->data = data + data_offset; UPB_UNPOISON_MEMORY_REGION(data, copy); memcpy(data, ptr, copy); - UPB_POISON_MEMORY_REGION(data + size, copy - size); + UPB_POISON_MEMORY_REGION(data + data_offset + size, + copy - data_offset - size); } #define FASTDECODE_COPYSTRING(d, ptr, msg, table, hasbits, data, tagbytes, \ @@ -697,18 +699,17 @@ static void fastdecode_docopy(upb_Decoder* d, const char* ptr, uint32_t size, \ if (UPB_LIKELY(size <= 15 - tagbytes)) { \ if (arena_has < 16) goto longstr; \ - d->arena.head.ptr += 16; \ - memcpy(buf, ptr - tagbytes - 1, 16); \ - dst->data = buf + tagbytes + 1; \ + fastdecode_docopy(d, ptr - tagbytes - 1, size, 16, buf, tagbytes + 1, \ + dst); \ } else if (UPB_LIKELY(size <= 32)) { \ if (UPB_UNLIKELY(common_has < 32)) goto longstr; \ - fastdecode_docopy(d, ptr, size, 32, buf, dst); \ + fastdecode_docopy(d, ptr, size, 32, buf, 0, dst); \ } else if (UPB_LIKELY(size <= 64)) { \ if (UPB_UNLIKELY(common_has < 64)) goto longstr; \ - fastdecode_docopy(d, ptr, size, 64, buf, dst); \ + fastdecode_docopy(d, ptr, size, 64, buf, 0, dst); \ } else if (UPB_LIKELY(size < 128)) { \ if (UPB_UNLIKELY(common_has < 128)) goto longstr; \ - fastdecode_docopy(d, ptr, size, 128, buf, dst); \ + fastdecode_docopy(d, ptr, size, 128, buf, 0, dst); \ } else { \ goto longstr; \ } \ @@ -917,6 +918,7 @@ static const char* fastdecode_tosubmsg(upb_EpsCopyInputStream* e, fastdecode_arr farr; \ \ if (subtablep->table_mask == (uint8_t)-1) { \ + d->depth++; \ RETURN_GENERIC("submessage doesn't have fast tables."); \ } \ \