Add more test coverage for arena registration.

PiperOrigin-RevId: 696606741
diff --git a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs b/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
deleted file mode 100644
index 208ce1f..0000000
--- a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.  All rights reserved.
-//
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file or at
-// https://developers.google.com/open-source/licenses/bsd
-#endregion
-
-namespace Google.Protobuf.Reflection;
-
-internal sealed partial class FeatureSetDescriptor
-{
-    // Canonical serialized form of the edition defaults, generated by embed_edition_defaults.
-    private const string DefaultsBase64 =
-        "ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH";
-}
diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel
index 7535d9c..c75dfa8 100644
--- a/src/google/protobuf/BUILD.bazel
+++ b/src/google/protobuf/BUILD.bazel
@@ -1734,6 +1734,7 @@
         ":cc_lite_test_protos",
         ":cc_test_protos",
         ":internal_visibility",
+        ":lite_test_util",
         ":port",
         ":protobuf",
         ":protobuf_lite",
@@ -1766,6 +1767,7 @@
         ":arena",
         ":cc_test_protos",
         ":internal_visibility",
+        ":lite_test_util",
         ":port",
         ":protobuf",
         ":protobuf_lite",
diff --git a/src/google/protobuf/compiler/cpp/file_unittest.cc b/src/google/protobuf/compiler/cpp/file_unittest.cc
index ad07b07..16cacf0 100644
--- a/src/google/protobuf/compiler/cpp/file_unittest.cc
+++ b/src/google/protobuf/compiler/cpp/file_unittest.cc
@@ -47,6 +47,7 @@
       "TestVerifyBigFieldNumberUint32.Nested",
       "TestUnpackedTypes",
       "TestUnpackedExtensions",
+      "TestString",
       "TestReservedFields",
       "TestRequiredOpenEnum",
       "TestRequiredOneof.NestedMessage",
diff --git a/src/google/protobuf/message_unittest.inc b/src/google/protobuf/message_unittest.inc
index 7f61658..723b8fd 100644
--- a/src/google/protobuf/message_unittest.inc
+++ b/src/google/protobuf/message_unittest.inc
@@ -41,6 +41,7 @@
 #include "absl/strings/cord.h"
 #include "absl/strings/substitute.h"
 #include "google/protobuf/arena.h"
+#include "google/protobuf/arena_test_util.h"
 #include "google/protobuf/descriptor.h"
 #include "google/protobuf/dynamic_message.h"
 #include "google/protobuf/generated_message_reflection.h"
@@ -58,6 +59,9 @@
 // Must be included last.
 #include "google/protobuf/port_def.inc"
 
+using ::testing::IsEmpty;
+using ::testing::Not;
+
 namespace google {
 namespace protobuf {
 
@@ -891,6 +895,17 @@
   ASSERT_EQ(test_all_types.DebugString(), msg_lite_pointer->DebugString());
 }
 
+TEST(MESSAGE_TEST_NAME, CordFieldGetsProperlyRegisteredInTheArena) {
+  Arena arena;
+  auto* msg = Arena::Create<UNITTEST::TestCord>(&arena);
+  // Very large input that needs allocation.
+  msg->set_optional_bytes_cord(std::string(1000, 'x'));
+  // Something should be registered for destruction.
+  EXPECT_THAT(internal::ArenaTestPeer::PeekCleanupListForTesting(&arena),
+              Not(IsEmpty()));
+  // We expect memory leaks here if the Cord was not properly destroyed.
+}
+
 #if GTEST_HAS_DEATH_TEST  // death tests do not work on Windows yet.
 
 TEST(MESSAGE_TEST_NAME, SerializeFailsIfNotInitialized) {
diff --git a/src/google/protobuf/unittest.proto b/src/google/protobuf/unittest.proto
index b6bb06e..7cdbcd2 100644
--- a/src/google/protobuf/unittest.proto
+++ b/src/google/protobuf/unittest.proto
@@ -2455,6 +2455,10 @@
   ];
 }
 
+message TestString {
+  string optional_string = 1;
+}
+
 message TestCord {
   bytes optional_bytes_cord = 1 [
     ctype = CORD