diff --git a/.github/workflows/test_php.yml b/.github/workflows/test_php.yml index 6319929495e7..0de97b47d6a7 100644 --- a/.github/workflows/test_php.yml +++ b/.github/workflows/test_php.yml @@ -12,160 +12,17 @@ permissions: contents: read jobs: - linux: - strategy: - fail-fast: false # Don't cancel all jobs if one fails. - matrix: - include: - - name: 7.3 Debug - version-short: "7.3" - version: 7.3.28-dbg - command: composer test \&\& composer test_c - - name: 7.4 Debug - version-short: "7.4" - version: 7.4.18-dbg - command: composer test \&\& composer test_c - - name: 8.0 Optimized - version: "8.0.5" - version-short: "8.0" - command: composer test \&\& composer test_c - - name: 8.0 Debug - version: 8.0.5-dbg - version-short: "8.0" - command: composer test \&\& composer test_c - - name: 8.0 Memory Leak - version: 8.0.5-dbg - version-short: "8.0" - # Run specialized memory leak & multirequest tests. - command: composer test_c \&\& tests/multirequest.sh \&\& tests/memory_leak_test.sh - - name: 8.0 Valgrind - version: 8.0.5-dbg - version-short: "8.0" - command: composer test_valgrind - - name: Linux ${{ matrix.name}} - runs-on: ubuntu-latest - steps: - - name: Checkout pending changes - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - ref: ${{ inputs.safe-checkout }} - submodules: recursive - - name: Setup composer - uses: protocolbuffers/protobuf-ci/composer-setup@v1 - with: - cache-prefix: php-${{ matrix.version-short }} - directory: php - - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 - with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php:${{ matrix.version }}-508417e5215994ade7585d28ba3aad681a25fa5d - credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - extra-flags: -e COMPOSER_HOME=/workspace/composer-cache - command: ${{ matrix.command }} - - linux-32bit: - strategy: - fail-fast: false # Don't cancel all jobs if one fails. - matrix: - version: ['7.4', '8.0'] - suffix: [ '', '-zts'] - test: ['test', 'test_c'] - exclude: - - suffix: '-zts' - test: 'test' - include: - - suffix: '-zts' - suffix_name: ' Thread Safe' - - test: 'test_c' - test_name: ' Extension' - - name: Linux 32-bit ${{ matrix.version}}${{ matrix.suffix_name }}${{ matrix.test_name }} - runs-on: ubuntu-latest - env: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/32bit@sha256:97f50ab24582380012d7ddef5f82f08e19b9dff55d09a4a8d90a87421ae66a45 - steps: - - name: Checkout pending changes - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - ref: ${{ inputs.safe-checkout }} - submodules: recursive - - - name: Cross compile protoc for i386 - id: cross-compile - uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1 - with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab - credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - architecture: linux-i386 - - - name: Setup composer - uses: protocolbuffers/protobuf-ci/composer-setup@v1 - with: - cache-prefix: php-${{ matrix.version }} - directory: php - - - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 - with: - image: ${{ env.image }} - skip-staleness-check: true - platform: linux/386 - credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - extra-flags: -e COMPOSER_HOME=/workspace/composer-cache -e PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} - command: >- - /bin/bash -cex ' - cd php && php -v && php -m; - composer update --ignore-platform-reqs; - PATH="/usr/local/php-${{ matrix.version }}${{matrix.suffix}}/bin:$PATH" - composer ${{ matrix.test }}' - - linux-aarch64: - name: Linux aarch64 - runs-on: ubuntu-latest - steps: - - name: Checkout pending changes - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - ref: ${{ inputs.safe-checkout }} - - - name: Cross compile protoc for aarch64 - id: cross-compile - uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1 - with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab - credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - architecture: linux-aarch64 - - - name: Setup composer - uses: protocolbuffers/protobuf-ci/composer-setup@v1 - with: - cache-prefix: php-7.3 - directory: php - - - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 - with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php-aarch64:0cc100b6e03d14c1e8f71ae794dc162ed122fe31@sha256:77b70feba68dced1f0fd21b52a08d3d2e0c5c797bfe68435a0038ce87ecfd310 - platform: linux/arm64 - skip-staleness-check: true - credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - extra-flags: -e COMPOSER_HOME=/workspace/composer-cache -e PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} - command: >- - -c ' - cd php; - composer update --ignore-platform-reqs; - composer test; - composer test_c' - macos: strategy: fail-fast: false # Don't cancel all jobs if one fails. matrix: version: ['7.4', '8.0'] + noop: [0,1,2,3,4,5] name: MacOS PHP ${{ matrix.version }} runs-on: macos-12 + env: + BAZEL_OSX_EXECUTE_TIMEOUT: 60 steps: - name: Checkout pending changes uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 @@ -198,6 +55,7 @@ jobs: with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: php_macos/${{ matrix.version }} + version: '6.1.0' bash: | pushd php php -v @@ -211,6 +69,7 @@ jobs: with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: php_macos/${{ matrix.version }} + version: '6.1.0' bash: >- bazelisk $BAZEL_STARTUP_FLAGS \ test $BAZEL_FLAGS \ diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index f82aa469fdb0..b8dbb9c38b8b 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -12,49 +12,14 @@ permissions: contents: read jobs: - linux: - strategy: - fail-fast: false # Don't cancel all jobs if one fails. - matrix: - type: [ Pure, C++] - version: [ "3.7", "3.8", "3.9", "3.10" ] - include: - - type: Pure - targets: //python/... @upb//python/... //python:python_version - flags: --define=use_fast_cpp_protos=false - - type: C++ - targets: //python/... //python:python_version - flags: --define=use_fast_cpp_protos=true - - type: C++ - version: aarch64 - targets: //python/... //python:aarch64_test - # TODO(b/262628111) Enable this once conformance tests are fixed. - flags: --define=use_fast_cpp_protos=true --test_tag_filters=-conformance - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-3af05275178e16af30961976af126eabbbb2c733 - - name: Linux ${{ matrix.type }} ${{ matrix.version }} - runs-on: ubuntu-latest - steps: - - name: Checkout pending changes - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - ref: ${{ inputs.safe-checkout }} - - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 - with: - image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/python:{0}-508417e5215994ade7585d28ba3aad681a25fa5d', matrix.version) }} - credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - bazel-cache: python_linux/${{ matrix.type }}_${{ matrix.version }} - bazel: test ${{ matrix.targets }} ${{ matrix.flags }} --test_env=KOKORO_PYTHON_VERSION - - macos: strategy: fail-fast: false # Don't cancel all jobs if one fails. matrix: type: [ Pure, C++] # TODO(b/267550843) Consider expanding this set of versions. - version: [ "3.10" ] + version: [ "3.7", "3.8", "3.9", "3.10" ] + noop: [0,1,2,3,4,5,6,7,8,9] include: - type: Pure targets: //python/... @upb//python/... //python:python_version @@ -64,6 +29,8 @@ jobs: name: MacOS ${{ matrix.type }} ${{ matrix.version }} runs-on: macos-12 + env: + BAZEL_OSX_EXECUTE_TIMEOUT: 60 steps: - name: Checkout pending changes uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 @@ -91,6 +58,7 @@ jobs: with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: python_macos/${{ matrix.type }}_${{ matrix.version }} + version: '6.1.0' bazel: >- test ${{ matrix.targets }} ${{ matrix.flags }} --test_env=KOKORO_PYTHON_VERSION=${{ matrix.version }} diff --git a/.github/workflows/test_ruby.yml b/.github/workflows/test_ruby.yml index 24b4122475bf..b2fa3192ef88 100644 --- a/.github/workflows/test_ruby.yml +++ b/.github/workflows/test_ruby.yml @@ -12,77 +12,18 @@ permissions: contents: read jobs: - linux: - strategy: - fail-fast: false - matrix: - include: - - { name: Ruby 2.6, ruby: ruby-2.6.0, bazel: 5.1.1} - - { name: Ruby 2.7, ruby: ruby-2.7.0, bazel: 5.1.1} - - { name: Ruby 3.0, ruby: ruby-3.0.2, bazel: 5.1.1} - - { name: Ruby 3.1, ruby: ruby-3.1.0, bazel: 5.1.1} - - { name: Ruby 3.2, ruby: ruby-3.2.0, bazel: 5.1.1} - - { name: JRuby 9.2, ruby: jruby-9.2.20.1, bazel: 5.1.1} - - { name: JRuby 9.3, ruby: jruby-9.3.4.0, bazel: 5.1.1} - - { name: Ruby 2.6 (Bazel6), ruby: ruby-2.6.0, bazel: 6.0.0} - - { name: JRuby 9.2 (Bazel6), ruby: jruby-9.2.20.1, bazel: 6.0.0} - - name: Linux ${{ matrix.name }} - runs-on: ubuntu-latest - steps: - - name: Checkout pending changes - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - ref: ${{ inputs.safe-checkout }} - - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 - with: - image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:{0}-{1}-508417e5215994ade7585d28ba3aad681a25fa5d', matrix.ruby, matrix.bazel) }} - credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - bazel-cache: ruby_linux/${{ matrix.ruby }}_${{ matrix.bazel }} - bazel: test //ruby/... //ruby/tests:ruby_version --test_env=KOKORO_RUBY_VERSION - - linux-aarch64: - name: Linux aarch64 - runs-on: ubuntu-latest - steps: - - name: Checkout pending changes - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - ref: ${{ inputs.safe-checkout }} - - - name: Cross compile protoc for aarch64 - id: cross-compile - uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1 - with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab - credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - architecture: linux-aarch64 - - - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 - with: - image: arm64v8/ruby:2.7.3-buster - skip-staleness-check: true - credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - command: >- - /bin/bash -cex ' - gem install bundler; - cd /workspace/ruby; - bundle; - PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} rake; - rake clobber_package gem; - PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} rake test' - macos: strategy: fail-fast: false # Don't cancel all jobs if one fails. matrix: # This is the full set of versions we support on MacOS. version: [ "2.7", "3.0", "3.1", "3.2" ] + noop: [0,1,2,3,4,5] name: MacOS Ruby ${{ matrix.version }} runs-on: macos-12 + env: + BAZEL_OSX_EXECUTE_TIMEOUT: 60 steps: - name: Checkout pending changes uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 @@ -101,42 +42,6 @@ jobs: uses: protocolbuffers/protobuf-ci/bazel@v1 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} + version: '6.1.0' bazel-cache: ruby_macos/${{ matrix.version }} bazel: test //ruby/... --test_env=KOKORO_RUBY_VERSION=${{ matrix.version }} - - test_ruby_gems: - strategy: - fail-fast: false - matrix: - include: - - { name: Ruby 2.6, ruby: ruby-2.6.0, bazel: 5.1.1} - - { name: Ruby 2.7, ruby: ruby-2.7.0, bazel: 5.1.1} - - { name: Ruby 3.0, ruby: ruby-3.0.2, bazel: 5.1.1} - - { name: Ruby 3.1, ruby: ruby-3.1.0, bazel: 5.1.1} - - { name: Ruby 3.2, ruby: ruby-3.2.0, bazel: 5.1.1} - - { name: JRuby 9.2, ruby: jruby-9.2.20.1, bazel: 5.1.1} - - { name: JRuby 9.3, ruby: jruby-9.3.4.0, bazel: 5.1.1} - - { name: Ruby 2.6 (Bazel6), ruby: ruby-2.6.0, bazel: 6.0.0} - - { name: JRuby 9.2 (Bazel6), ruby: jruby-9.2.20.1, bazel: 6.0.0} - name: Install ${{ matrix.name }} - runs-on: ubuntu-latest - steps: - - name: Checkout pending changes - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - ref: ${{ inputs.safe-checkout }} - - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 - with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:${{ matrix.ruby }}-${{ matrix.bazel }}-508417e5215994ade7585d28ba3aad681a25fa5d - credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - bazel-cache: ruby_install/${{ matrix.ruby }}_${{ matrix.bazel }} - bash: > - bazel --version; - ruby --version; - bazel build //ruby:release //:protoc $BAZEL_FLAGS; - gem install bazel-bin/ruby/google-protobuf-*; - bazel-bin/protoc --proto_path=src --proto_path=ruby/tests --proto_path=ruby --ruby_out=ruby tests/test_import_proto2.proto; - bazel-bin/protoc --proto_path=src --proto_path=ruby/tests --proto_path=ruby --ruby_out=ruby tests/basic_test.proto; - ruby ruby/tests/basic.rb - diff --git a/.github/workflows/test_runner.yml b/.github/workflows/test_runner.yml index 51ac629a6a6f..06ffade5e1af 100644 --- a/.github/workflows/test_runner.yml +++ b/.github/workflows/test_runner.yml @@ -101,21 +101,6 @@ jobs: # Note: this pattern of passing the head sha is vulnerable to PWN requests for # pull_request_target events. We carefully limit those workflows to require a # human stamp before continuing. - cpp: - name: C++ - needs: [check-tag] - uses: ./.github/workflows/test_cpp.yml - with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} - secrets: inherit - - java: - name: Java - needs: [check-tag] - uses: ./.github/workflows/test_java.yml - with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} - secrets: inherit python: name: Python @@ -141,22 +126,6 @@ jobs: safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} secrets: inherit - php-ext: - name: PHP Extension - needs: [check-tag] - uses: ./.github/workflows/test_php_ext.yml - with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} - secrets: inherit - - csharp: - name: C# - needs: [check-tag] - uses: ./.github/workflows/test_csharp.yml - with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} - secrets: inherit - objectivec: name: Objective-C needs: [check-tag] diff --git a/python/google/protobuf/message.py b/python/google/protobuf/message.py index efade7ce2a36..ad0f9c3c6cf4 100755 --- a/python/google/protobuf/message.py +++ b/python/google/protobuf/message.py @@ -404,6 +404,7 @@ def __setstate__(self, state): self.ParseFromString(serialized) def __reduce__(self): + message_descriptor = None message_descriptor = self.DESCRIPTOR if message_descriptor.containing_type is None: return type(self), (), self.__getstate__() diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index 6577a3669217..9ffd8657725c 100644 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -559,7 +559,8 @@ ArenaBlock* ThreadSafeArena::FirstBlock(void* buf, size_t size, ABSL_DCHECK_EQ(reinterpret_cast(buf) & 7, 0u); SizedPtr mem; - if (buf == nullptr || size < kBlockHeaderSize + kAllocPolicySize) { + static void* kNull = 0; + if (buf == kNull || size < kBlockHeaderSize + kAllocPolicySize) { mem = AllocateMemory(&policy, 0, kAllocPolicySize); } else { mem = {buf, size}; diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 61d756b7903d..d93ced8f28de 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -111,6 +111,8 @@ void arena_delete_object(void* object) { } } // namespace internal +constexpr char* kNullptr4 = nullptr; + // ArenaOptions provides optional additional parameters to arena construction // that control its block-allocation behavior. struct ArenaOptions { @@ -128,7 +130,7 @@ struct ArenaOptions { // provided, the block must live at least as long as the arena itself. The // creator of the Arena retains ownership of the block after the Arena is // destroyed. - char* initial_block = nullptr; + char* initial_block = kNullptr4; // The size of the initial block, if provided. size_t initial_block_size = 0;