Commit graph

1498 commits

Author SHA1 Message Date
Protobuf Team Bot
80d472933a Auto-generate files after cl/966337187 2026-08-18 03:47:16 +00:00
Protobuf Team Bot
9ff0d2d197 Auto-generate files after cl/966266256 2026-08-18 00:27:25 +00:00
Protobuf Team Bot
dc693bc891 Auto-generate files after cl/966151323 2026-08-17 20:42:12 +00:00
Protobuf Team Bot
011fbe69e9 Auto-generate files after PR #28553 2026-08-12 19:45:18 +00:00
Protobuf Team Bot
c2cbda5b47 Auto-generate files after PR #28900 2026-08-12 16:08:15 +00:00
Protobuf Team Bot
f5fba07925 Auto-generate files after cl/963471731 2026-08-12 16:04:41 +00:00
Protobuf Team Bot
0939462046 Auto-generate files after cl/963394074 2026-08-12 13:14:09 +00:00
Hiroshi SHIBATA
dce0d24702 Fix google-protobuf gem source build on the mswin platform (#28433)
`gem install google-protobuf --platform ruby` fails on Windows with the native mswin toolchain (`x64-mswin64_140`, `cl.exe` and `nmake`). `Init_protobuf_c` in `protobuf.c` is annotated with the GCC-style `__attribute__((visibility("default")))`, which `cl.exe` cannot parse and rejects with a cascade of C2143/C2091 syntax errors. In addition, `extconf.rb` passes GCC-only flags (`-std=gnu99`, `-O3`, `-fvisibility=hidden`) that `cl.exe` does not understand.

This change replaces the attribute with Ruby's portable `RUBY_FUNC_EXPORTED` macro, which expands to `extern __declspec(dllexport)` under MSVC and to `__attribute__((__visibility__("default"))) extern` under GCC/Clang, so the symbol stays exported when the extension is built with `-fvisibility=hidden`. It also gives mswin its own `$CFLAGS` branch. `-std:c11` is required there because the MSVC atomics fallback in upb only uses its `_Generic` based implementation when `__STDC_VERSION__` is at least 201112L. The pre-C11 fallback returns `void*` from `upb_Atomic_Load`, and mswin Ruby compiles extensions with `-we4047` by default, which turns those conversion warnings into hard errors.

Verified on Windows 11 with Ruby 4.0.5 (`x64-mswin64_140`) and Visual Studio 2022 Build Tools (MSVC 14.51). Building the extension in-tree succeeds, and a gem built from the released 4.35.1 sources with this patch applied installs successfully and passes a `Struct` and `Timestamp` encode/decode round-trip. Precompiled `x64-mingw-ucrt` gems are unaffected because MinGW keeps using the existing GCC branch.

Generated with [Claude Code](https://claude.com/claude-code)

Closes #28433

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/28433 from hsbt:claude/elated-goldwasser-3862b4 7d533bab6c
PiperOrigin-RevId: 963158243
2026-08-11 20:03:36 -07:00
Jeremy Daer
7d7d6ab836 Ruby: fix use-after-free of map keys aliasing a temporary String (#29026)
Fixes #29023.

`Map#[]=` and `Message.new(map_field: {...})` build the map key as a `upb_StringView`
aliasing a Ruby String, then convert the value before `upb_Map_Set` copies the key. The
value conversion allocates, so it can trigger GC inside that window.

The aliased String is frequently a **temporary**: `Convert_RubyToUpb` replaces the caller's
object when the key is a Symbol (via `to_s`) or a String not already tagged UTF-8 (via
`Convert_CheckStringUtf8`), and nothing references the result once it returns. When GC
collects it, the freed block goes straight back to the next `upb_Arena_Malloc`, which
memcpys the *value* into it — leaving a silently corrupted key holding unrelated heap bytes,
tagged UTF-8 while containing invalid UTF-8, which then propagates into `encode`/`to_json`.

## The fix

Pass the arena at both insertion sites, so the key is copied before anything can allocate.

The lookup paths (`Map_index`, `Map_has_key`, `Map_delete`) keep the `NULL` fast path — they
consume the key immediately with no allocation in between, which is exactly the precondition
`Convert_StringData`'s comment describes. I reworded that comment, since it read as though
the aliasing were unconditionally safe; it holds for three of its five callers and not for
the two that insert.

Cost is one arena allocation per insert for string-typed keys. Non-string keys don't reach
`Convert_StringData` at all.

## Trigger

Needs both:

- a key that is a **Symbol**, or a String not already tagged UTF-8 — `ASCII-8BIT` is the
  common case for anything read from a socket, a file, `Marshal`, or `String#pack`; and
- a value whose conversion allocates (a Symbol, or a non-UTF-8 String).

Plain UTF-8 keys are unaffected, which is presumably why this has gone unnoticed.

## Verification

Reproduces under **ordinary GC**, no `GC.stress` required — one corrupted key across 150k
iterations (0/50k, 0/50k, 1/50k), versus 100/100 with stress. That second number is an
existence proof rather than a rate.

Added regression tests to `ruby/tests/gc_test.rb` covering string keys, Symbol keys, and the
map-field kwarg path. Verified red/green against the same tree:

| ext build | new tests |
|---|---|
| unpatched `main` | 3 tests, **3 failures** |
| with this change | 3 tests, 300 assertions, **0 failures** |

Full Ruby suite green with the change on ruby 4.0.6 / arm64-darwin — `basic.rb` (133 tests,
157,864 assertions), `basic_proto2.rb` (93), `repeated_field_test.rb` (40),
`encode_decode_test.rb`, `memory_test.rb`, `object_cache_test.rb`, `well_known_types_test.rb`,
`service_test.rb`, `oom_test.rb`, `multi_level_nesting_test.rb` — 0 failures, 0 errors.

Reported separately via the channel in `SECURITY.md`, since this is a memory-safety issue in
an OT0 repository.

Closes #29026

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/29026 from jeremy:ruby-map-key-use-after-free e11cc7dfe2
PiperOrigin-RevId: 961236703
2026-08-07 19:44:44 -07:00
Protobuf Team Bot
94c7e8ebc1 Auto-generate files after cl/960627263 2026-08-07 02:08:48 +00:00
Protobuf Team Bot
f23e709bcf Auto-generate files after cl/960555713 2026-08-06 23:32:03 +00:00
Protobuf Team Bot
de3eafeda5 Auto-generate files after cl/959880585 2026-08-05 21:59:29 +00:00
Protobuf Team Bot
f11e6f301a Auto-generate files after cl/959372170 2026-08-05 03:12:27 +00:00
Matthew Wear
ae3f25c964 ruby: make bigdecimal a development dependency (#28928)
Fixes #28927

I ran into this while packaging the OpenTelemetry Ruby auto-instrumentation as a prebuilt gem bundle (see #28927 for the full write up). The tl;dr: `bigdecimal` is only used by the test suite, so it only needs to be a development dependency. The only references are:

8baed752ce/ruby/tests/common_tests.rb (L9)

8baed752ce/ruby/tests/common_tests.rb (L1708)

As a runtime dependency it causes pain for anyone vendoring the gem. `bigdecimal` is a native extension with no precompiled build, so it has to be compiled from source for each Ruby ABI, making it the one gem that stops a prebuilt bundle from working across Ruby versions, despite never being loaded at runtime.

This PR moves `bigdecimal` from a runtime to a development dependency. For consistency it also moves `bigdecimal` into the `test` group in the Gemfile, since that's the only environment that needs it.

Closes #28928

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/28928 from mwear:ruby-bigdecimal-dev-dependency 6fb8ee4fad
PiperOrigin-RevId: 957450742
2026-07-31 19:47:08 -07:00
Jason Aragorn Tobias Lunn
713b6a4a24 Add json_options.proto and json_enumvalue_options.proto and/or gencode derived from them to release artifacts
* `protoc`: Included in zips alongside binary
* Java: Generated classes have been added to the Maven `util` artifact
* Ruby: Generated classes have been added to gems
* CMake: `.proto` files are included in installation

PiperOrigin-RevId: 957382561
2026-07-31 16:20:59 -07:00
Protobuf Team Bot
7c02abb54a Auto-generate files after cl/957163354 2026-07-31 16:00:30 +00:00
Protobuf Team Bot
8baed752ce Auto-generate files after cl/956632937 2026-07-30 18:29:41 +00:00
Protobuf Team Bot
a772068fea Auto-generate files after cl/956087593 2026-07-29 21:34:38 +00:00
Protobuf Team Bot
b97149ff4f Auto-generate files after cl/956061501 2026-07-29 20:50:21 +00:00
Protobuf Team Bot
60f509fa40 Auto-generate files after cl/955926792 2026-07-29 16:41:03 +00:00
Protobuf Team Bot
43b6c37509 Handle ruby allocation failures gracefully
Prior to this change, the custom alloc function used with arenas would internally longjmp on allocation failure, which would then leak memory (as upb does not expect or permit longjmp from an alloc function, and has no way to free intermediate allocations).

PiperOrigin-RevId: 955635829
2026-07-28 21:08:09 -07:00
Protobuf Team Bot
21bfc8ad38 Auto-generate files after cl/955347939 2026-07-28 18:04:47 +00:00
Protobuf Team Bot
6d7f56cbac Auto-generate files after cl/955260241 2026-07-28 15:19:20 +00:00
Protobuf Team Bot
6f2e31b2b8 Auto-generate files after cl/955047292 2026-07-28 06:26:07 +00:00
Protobuf Team Bot
232f2fbd50 Auto-generate files after cl/955022274 2026-07-28 05:21:33 +00:00
Protobuf Team Bot
545f3bafe4 Auto-generate files after cl/954919110 2026-07-28 00:36:08 +00:00
Protobuf Team Bot
3094f87854 Auto-generate files after cl/953447806 2026-07-24 18:00:16 +00:00
Protobuf Team Bot
8815f682d8 Auto-generate files after cl/952535247 2026-07-23 06:06:35 +00:00
Protobuf Team Bot
e9aa0183c7 Auto-generate files after cl/951099608 2026-07-20 23:07:13 +00:00
Protobuf Team Bot
bf735f2bba Auto-generate files after cl/950998569 2026-07-20 20:01:10 +00:00
Protobuf Team Bot
b472eb92ff Auto-generate files after cl/949697167 2026-07-17 19:26:48 +00:00
Protobuf Team Bot
6d5557a46f Auto-generate files after cl/949190424 2026-07-16 22:07:39 +00:00
Protobuf Team Bot
79756f62ab Auto-generate files after cl/949108864 2026-07-16 19:36:32 +00:00
Protobuf Team Bot
917911a3bb Auto-generate files after cl/948707011 2026-07-16 03:54:03 +00:00
Protobuf Team Bot
9c3a5143de Auto-generate files after cl/948094363 2026-07-15 05:08:57 +00:00
Protobuf Team Bot
3bc006d2c1 Auto-generate files after cl/947760935 2026-07-14 17:31:32 +00:00
Protobuf Team Bot
44a1a0bbc3 Auto-generate files after PR #28231 2026-07-14 05:43:50 +00:00
Protobuf Team Bot
255635a7fa Auto-generate files after cl/947129093 2026-07-13 18:03:08 +00:00
Protobuf Team Bot
774721742b Auto-generate files after cl/947071987 2026-07-13 16:16:12 +00:00
Protobuf Team Bot
cb2c93944e Auto-generate files after cl/945959296 2026-07-11 00:09:26 +00:00
rgoldfinger6
4b269eb436 Updating version.json and repo version numbers to: 37.0-dev (#28425)
NOTE: This should be reviewed and imported via Copybara per the normal PR review process.

Closes #28425

PiperOrigin-RevId: 945675238
2026-07-10 06:22:59 -07:00
Protobuf Team Bot
e22cabffa4 Auto-generate files after cl/945282190 2026-07-09 20:35:22 +00:00
Protobuf Team Bot
1eb5913459 Auto-generate files after cl/944789082 2026-07-09 00:33:26 +00:00
Protobuf Team Bot
648080151f Auto-generate files after cl/944782315 2026-07-09 00:17:24 +00:00
Protobuf Team Bot
5e24bccb66 Auto-generate files after cl/944116273 2026-07-07 22:24:32 +00:00
Protobuf Team Bot
f98ab0592f Set JRuby dev flag on conformance tests to reduce 30s timeouts
PiperOrigin-RevId: 943900327
2026-07-07 08:15:50 -07:00
Jason Aragorn Tobias Lunn
7008dd1aa7 Drop support for Ruby 3.1
PiperOrigin-RevId: 943899182
2026-07-07 08:11:48 -07:00
Jason Aragorn Tobias Lunn
b70d2497e2 Add test for RepeatedField concatenation and arena lifetime.
PiperOrigin-RevId: 943843380
2026-07-07 05:59:28 -07:00
Protobuf Team Bot
65a15e586d Auto-generate files after cl/943010563 2026-07-06 03:02:36 +00:00
Protobuf Team Bot
050bd07378 Auto-generate files after cl/941296469 2026-07-01 21:39:42 +00:00