Commit Graph

1680 Commits

Author SHA1 Message Date
GitHub Actions
d7606f6db9 Update artifacts branch 2025-06-03 20:12:56 +00:00
GitHub Actions
7dea6ec75e Update artifacts branch 2025-05-27 17:56:42 +00:00
Tanvi Jagtap
f416b31eec [Gpr_To_Absl_Logging] Remove gpr_log_severity_string (#37013)
[Gpr_To_Absl_Logging] Remove gpr_log_severity_string

This function is not getting used anymore gpr_log_severity_string

Closes #37013

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37013 from tanvi-jagtap:gpr_log_severity_string_remove 3346face4c1b5262e3af8f394f3c75729391ad6b
PiperOrigin-RevId: 645796077
2024-06-23 00:30:21 -07:00
apolcyn
e1530b1c88 [ruby] Update google-protobuf dep to allow 3.x and 4.x versions (#36982)
As title

`_pb.rb` protos regenerated using `grpc-tools` 1.64, which has a more recent `protoc`. (otherwise tests fail b/c we can't load the older generated code with google-protobuf 4.x - also see https://github.com/grpc/grpc/pull/36900#issuecomment-2163871696

cc @dazuma @alto-ruby

Closes #36982

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36982 from apolcyn:update_dep 84de585b421c9be5ff9f1f736278d2f82eb9c764
PiperOrigin-RevId: 645189362
2024-06-20 16:29:11 -07:00
Hoa Nguyen
b18636ef21 [Ruby] Implement setter for logger of GRPC module (#36989)
This commit implements `logger=` for GRPC module. It will allow us to inject a custom logger on the fly easily. Using `self.extend` inside this setter will help us deal with backward compatible for some custom Logger Module.

<!--

Your pull request will be routed to the following person by default for triaging.
If you know who should review your pull request, please remove the mentioning below.

-->

Fixed #24084

cc @sampajano , @apolcyn and @alto-ruby TIA

re: https://github.com/grpc/grpc/pull/24072

Closes #36989

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36989 from nvh0412:chore/add-logger-setter-for-GRPC-ruby-2 f5a91225e7e1b08cfd7b99e2ed8231f0cf3d75a7
PiperOrigin-RevId: 645189146
2024-06-20 16:24:36 -07:00
Tanvi Jagtap
4c9db803a2 [Gpr_To_Absl_Logging] Fixing bugs (#36961)
### Problem 1

Context :
gpr_log() internally calls gpr_log_message() .
gpr_log_message() may either call gpr_default_log() or a user provided logging function.
gpr_default_log() uses absl LOG. This is the default. Most users will log this way.
For the small percentage of users who have customized the logging function, gpr_log will log to custom this function.

Problem :
We have converted half the instances of gpr_log to absl LOG().
For users who use the defaults - there will be no issue.
For the users who use a customized logging function
1. All the absl LOGs will log to the absl log sink.
2. All the gpr_log statements will log via this user provided function.
This is in-consistent behaviour and will cause confusion and difficulty in debugging.

Solution:
All logs should go to the same sink.
So we decided to make gpr_set_log_function a no op in this release.
The function will be deleted in the next release.
https://github.com/grpc/proposal/pull/425

### Problem 2

Context :
gpr_should_log is used to avoid computing expensive stuff for logging if the log is not going to be visible.

Problem :
gpr_should_log was referencing the GRPC_VERBOSITY flag and values set by gpr_set_log_verbosity .
However, actual logging happens based on the absl settings.
This is incorrect. Because if the old settings are not honoured, they should not be checked and no decision in code should be made based on settings which are not going to get used.

Solution :
Given the above changes in Problem 1, since all custom logging is disabled, all logging from gRPC with honour the absl LOG settings. Hence we modified the gpr_should_log function to refer to absl settings.

### Problem 3

We still have the issue of php using a custom log sink. We will address this in a separate PR.

### Problem 4

Tests related to test/core/end2end/tests/no_logging.cc are broken . These will be fixed in another PR.

Closes #36961

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36961 from tanvi-jagtap:fix_gpr_should_log 70c3224af16ba14ce9f1b58fa659d69fa8278eb3
PiperOrigin-RevId: 645096418
2024-06-20 11:17:34 -07:00
Tanvi Jagtap
4c01a30f37 [grpc][Gpr_To_Absl_Logging] Remove gpr_assertion_failed function (#36912)
[grpc][Gpr_To_Absl_Logging] Remove gpr_assertion_failed function

Closes #36912

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36912 from tanvi-jagtap:remove_gpr_assertion_failed faded6fd6d498ae935a5748c6402aa701e5538ef
PiperOrigin-RevId: 643699881
2024-06-15 21:22:44 -07:00
Tanvi Jagtap
97b9560345 [Gpr_To_Absl_Logging] Fixing ruby build (#36935)
Fixing ruby build.

GPR_ASSERT function has been deleted.

Closes #36935

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36935 from tanvi-jagtap:fix_ruby_build e82f026dde5e138c6bb5043b4bd148f3c0530fd6
PiperOrigin-RevId: 643618811
2024-06-15 09:09:50 -07:00
apolcyn
d4b5e12f8e [ruby] improve the way completion queue pluck operations handle signals and process shutdown (#36903)
Fixes the CBF of `src/ruby/end2end/killed_client_thread_test.rb` (failure mode is a hang of the child process that receives the SIGTERM) that has been happening since https://github.com/grpc/grpc/pull/36724

So far grpc-ruby CQ pluck operations have so far used a 20ms-interval busy poll to check interrupts in case we've received a signal, handle process shutdown, etc. This means ongoing RPCs will not terminate their CQ operations if we need to terminate the process (the loop simply exits without waiting for the CQ op to finish), causing a leak. Those RPCs can leave refs over their corresponding channels preventing [this](8564f72e8e/src/ruby/ext/grpc/rb_channel.c (L653)) from terminating (the channels don't reach state SHUTDOWN after being destroyed).

Fix is to unblock CQ pluck operations by cancelling calls, and thus allowing the CQ pluck to actually complete its operation. For server listening CQ operations, we unblock them by shutting down the server.

A side win here is to remove the [20ms-interval busy poll](8564f72e8e/src/ruby/ext/grpc/rb_completion_queue.c (L44)) on CQ operations, which was only needed to handle shutdown.

Closes #36903

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36903 from apolcyn:fix_ruby_interrupt bed1ee2feba4f7e2977cc29f921c7b37a84d3407
PiperOrigin-RevId: 643046465
2024-06-13 10:36:44 -07:00
Xuan Wang
f87084d64f [Release] Bump version to 1.66.0-dev (on master branch) (#36892)
Change was created by the release automation script. See go/grpc-release.

Closes #36892

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36892 from XuanWang-Amos:bump_dev_version_202406112301 9b2898d716af0d8dcd90aab23e35959cd6c38855
PiperOrigin-RevId: 643027546
2024-06-13 09:40:37 -07:00
Tanvi Jagtap
8a30491657 [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36817)
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT
Replacing GPR_ASSERT with c assert.
These changes have been made using string replacement and regex.

Closes #36817

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36817 from tanvi-jagtap:gpr_assert_removal_in_php 2222f9541314679e5a73f301bfafd5a70f280471
PiperOrigin-RevId: 642855768
2024-06-12 22:54:12 -07:00
Tanvi Jagtap
03e91b6811 [Gpr_To_Absl_Logging] Move function to test header form log.h (#36860)
[Gpr_To_Absl_Logging] Move function to test header form log.h
This is not really needed in log.h

Closes #36860

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36860 from tanvi-jagtap:move_function_to_test_header e6494bd06f2e4a08c91eb41f420607f9568b22ac
PiperOrigin-RevId: 642080756
2024-06-10 17:52:44 -07:00
Tanvi Jagtap
1dbfd4c9f2 [grpc][Gpr_To_Absl_Logging] Deleting multiple instances of gpr_set_log_function (#36833)
Deleting multiple instances of gpr_set_log_function .
This function will be deleted soon.
https://github.com/grpc/proposal/pull/425

Closes #36833

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36833 from tanvi-jagtap:remove_gpr_log_partial_code 17517efee4795eb6e5ff7670252e7329c9cf12d7
PiperOrigin-RevId: 641268299
2024-06-07 09:14:44 -07:00
Yash Tibrewal
87b71907d6 [Release] Bump version to 1.65.0-dev (on master branch) (#36544)
Change was created by the release automation script. See go/grpc-release.

Closes #36544

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36544 from yashykt:bump_dev_version_202405061956 69ee5c869efa544c0ce768792750720df9d11f07
PiperOrigin-RevId: 631187829
2024-05-06 14:41:36 -07:00
AJ Heller
1a8b22f2de [build] Restrict visibility for creating core credentials types. (#36216)
Closes #36216

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36216 from drfloob:conceal-core-cred-creation a44a2992736c2c45c044452ec892e6ac4d173b7b
PiperOrigin-RevId: 625425746
2024-04-17 01:21:29 +00:00
Yijie Ma
cd30592193 [release] Bump dev version 202404101721 (#36333)
<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #36333

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36333 from yijiem:bump_dev_version_202404101721 0a7cc5b4b740688b81417ef2da8f93b4c027f3ed
PiperOrigin-RevId: 623878150
2024-04-11 11:04:35 -07:00
Jean byroot Boussier
930b3934bc ruby: register grpc_rb_sStatus as a global variable (#36125)
Ref: https://bugs.ruby-lang.org/issues/20311

C global variable that contain references to Ruby object MUST be declared to the Ruby GC to prevent these objects from being collected or moved.

There are a few exceptions to that, such as classes defined using the C APIs such as `rb_define_class` etc.

Up to Ruby 3.4 however, there was a bug that caused classes created from Ruby with the `Struct.new("Name")` API to also be marked as immortal and immovable.

GRPC has been relying on this bug, which I fixed in Ruby 3.4, and now GRPC is crashing when `Struct::Status` is moved around by the GC.

```
-- C level backtrace information -------------------------------------------
ruby(rb_print_backtrace+0x14) [0x5577db219d41] ruby-3.4.0/vm_dump.c:820
ruby(rb_vm_bugreport) ruby-3.4.0/vm_dump.c:1151
ruby(rb_bug_for_fatal_signal+0xfc) [0x5577db3cc60c] ruby-3.4.0/error.c:1066
ruby(sigsegv+0x4d) [0x5577db16358d] ruby-3.4.0/signal.c:926
libc.so.6(0x7f5bacd32520) [0x7f5bacd32520]
ruby(rb_class_superclass+0x32) [0x5577db0a9152] ruby-3.4.0/object.c:2239
ruby(struct_ivar_get+0x2a) [0x5577db194e02] ruby-3.4.0/struct.c:49
ruby(struct_ivar_get) ruby-3.4.0/struct.c:40
ruby(num_members) ruby-3.4.0/struct.c:705
ruby(rb_struct_new+0x56) [0x5577db19a9d6] ruby-3.4.0/struct.c:848
lib/grpc/grpc_c.so(grpc_run_batch_stack_build_result+0xe6) [0x7f5b84bb6b96] /tmp/bundle/ruby/3.4.0+0/bundler/gems/grpc-5ed33ee673e3/src/ruby/ext/grpc/rb_call.c:780
lib/grpc/grpc_c.so(grpc_rb_call_run_batch_try) /tmp/bundle/ruby/3.4.0+0/bundler/gems/grpc-5ed33ee673e3/src/ruby/ext/grpc/rb_call.c:839
ruby(rb_ensure+0x10c) [0x5577db007d3c] ruby-3.4.0/eval.c:1000
/tmp/bundle/ruby/3.4.0+0/bundler/gems/grpc-5ed33ee673e3/src/ruby/lib/grpc/grpc_c.so(grpc_rb_call_run_batch+0xca) [0x7f5b84bb595a] /tmp/bundle/ruby/3.4.0+0/bundler/gems/grpc-5ed33ee673e3/src/ruby/ext/grpc/rb_call.c:893
ruby(vm_call_cfunc_with_frame_+0x117) [0x5577db1f4c77] ruby-3.4.0/vm_insnhelper.c:3524
```

cc @apolcyn @peterzhu2118 @k0kubun

Closes #36125

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36125 from Shopify:fix-ruby-3.4-compat 7a127599c8385a1c3794c7788e034c41710a8f9b
PiperOrigin-RevId: 616152904
2024-03-15 09:27:32 -07:00
Stan Hu
489d24cf7e [ruby] Make GRPC::DeadlineExceeded report properly (#33565)
In grpc v1.46.2 and later versions, #29155 caused the Ruby client to return `GRPC::Core::CallError`, a non-standard error, with a message: `grpc_call_start_batch failed with outstanding read or write present (code=8)`. However, the actual error should have been `GRPC::DeadlineExceeded`. This occurred because when `GRPC::DeadlineExceeded` is raised, the `@metadata_received` flag doesn't get flipped. When `receive_and_check_status` runs to determine
the error, the `RECV_INITIAL_METADATA` is erroneously sent again.

To avoid this, flip the flag in an `ensure` block whenever the `RECV_INITIAL_METADATA` op is set.

Closes #33283

Closes #33565

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/33565 from stanhu:sh-ruby-fix-issue-33283 850889558cf070e5e7b6eb471d71a61300b3442f
PiperOrigin-RevId: 614088694
2024-03-08 17:20:56 -08:00
Esun Kim
7b98cda1f4 No public description
PiperOrigin-RevId: 613626993
2024-03-07 10:26:42 -08:00
Esun Kim
34be0d84a9 [Core] Remove wrap_memcpy (#35826)
gRPC has been having the `wrap_memcpy` workaround to handle the breaking change of `memcpy` on glibc 2.14 ([ref1](https://www.win.tue.nl/~aeb/linux/misc/gcc-semibug.html), [ref2](https://stackoverflow.com/questions/35656696/explanation-of-memcpy-memmove-glibc-2-14-2-2-5)). This was necessary to build more portable artifacts which are expected to run on most linux distributions and we manged to have https://github.com/grpc/grpc/pull/5007 years ago for this.

Since we started to use manylinux2010-based docker images for artifacts, however, this became unnecessary since CentOS 6 has glibc 2.12 which is older than 2.14 so it doesn't have memcpy issue, which is another benefit of using manylinux2010.

Superseding https://github.com/grpc/grpc/pull/23385
Changes after the original PR was made; Ruby is using manylinux images (manylinux2014) enabling this change, no more old docker images in our test env.

Closes #35826

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35826 from veblush:del-wrap-memcpy-2 71e6718356b2b6684bb7e977fe66ef39561c05a7
PiperOrigin-RevId: 607499060
2024-02-15 16:53:19 -08:00
Eugene Ostroukhov
6c157f9128 [Release] Bump version to 1.63.0-dev (on master branch) (#35899)
Change was created by the release automation script. See go/grpc-release.

Closes #35899

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35899 from eugeneo:bump_dev_version_202402131133 73950425c9f00d56ce8d6b9f2f36f69b6dce4a40
PiperOrigin-RevId: 606777850
2024-02-13 16:09:36 -08:00
Mark D. Roth
574b0572f1 [client channel] remove grpc_channel_num_external_connectivity_watchers() (#35840)
Implements gRFC L113 (https://github.com/grpc/proposal/pull/417).

Closes #35840

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35840 from markdroth:client_channel_remove_num_external_watchers 334670c13c29b754a2483f25678ade2ce6bf1bfb
PiperOrigin-RevId: 606766495
2024-02-13 15:31:33 -08:00
Stan Hu
c637a9f82b [ruby] Fix compilation errors on clang 16 (#34481)
As announced in https://discourse.llvm.org/t/clang-16-notice-of-potentially-breaking-changes/65562, clang 16 defaults `-Wincompatible-function-pointer-types` to be on. This causes a number of hard errors due to implicit conversions between `void *` and `void`, such as:

```
../../../../src/ruby/ext/grpc/rb_channel.c:770:47: error: incompatible function pointer types passing 'VALUE (VALUE)' (aka 'unsigned long (unsigned long)') to parameter of type 'VALUE (*)(void *)' (aka 'unsigned long (*)(void *)') [-Wincompatible-function-pointer-types]
  g_channel_polling_thread = rb_thread_create(run_poll_channels_loop, NULL);
                                              ^~~~~~~~~~~~~~~~~~~~~~
/root/.rbenv/versions/3.1.4/include/ruby-3.1.0/ruby/internal/intern/thread.h:190:32: note: passing argument to parameter 'f' here
VALUE rb_thread_create(VALUE (*f)(void *g), void *g);
                               ^
../../../../src/ruby/ext/grpc/rb_channel.c:780:41: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
void grpc_rb_channel_polling_thread_stop() {
                                        ^
                                         void
../../../../src/ruby/ext/grpc/rb_channel.c:786:30: error: incompatible function pointer types passing 'void (void *)' to parameter of type 'void *(*)(void *)' [-Wincompatible-function-pointer-types]
  rb_thread_call_without_gvl(run_poll_channels_loop_unblocking_func, NULL, NULL,
```

This commit fixes these pointer types using wrapper functions where necessary.

This issue was also raised on the FreeBSD port of the grpc gem: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271540

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #34481

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/34481 from stanhu:sh-ruby-fix-clang-16 63c7424ad0c93f7a7aa1ce0e84ea7916c4cbdc5f
PiperOrigin-RevId: 600548467
2024-01-22 13:13:30 -08:00
Esun Kim
fe75f2b5ff [GPR] Removed GPR_BACKWARDS_COMPATIBILITY_MODE (#35602)
`GPR_BACKWARDS_COMPATIBILITY_MODE` was devised to support old Linux kernel with old glibc but gRPC is now expected to support glibc 2.17 and later (2.17 is derived from the oldest but supported Linux distro, CentOS 7). Effectively, gRPC doesn't need `GPR_BACKWARDS_COMPATIBILITY_MODE` anymore. Hence, let's remove it.

gRPC Python and Ruby that distribute binary artifacts already began to use `manylinux` environment dealing with this issue in a better way so they don't need this flag anymore.

Closes #35602

PiperOrigin-RevId: 599895270
2024-01-19 12:48:26 -08:00
Alan Wu
b85ebb9bba [ruby] Fix use-after-free for post-fork channel recreation (#35488)
The `grpc_channel_args` is retained on the Ruby object and used for recreating the channel after forking in
grpc_rb_channel_maybe_recreate_channel_after_fork(). Previously, the key for each argument was taken from a Ruby string directly, which could be invalidated if the Ruby string is modified or moved by the GC. Duplicate the string for the key instead, so we own it.

Reproducer in https://github.com/grpc/grpc/issues/35489

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #35488

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35488 from Shopify:key-uaf c1813cee0184a5003f01dd1086df4f322917281b
PiperOrigin-RevId: 599304551
2024-01-17 15:19:45 -08:00
Stanley Cheung
7c347b96eb [Release] Bump version to 1.62.0-dev (on master branch) (#35580)
Change was created by the release automation script. See go/grpc-release.

Closes #35580

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35580 from stanley-cheung:bump_dev_version_202401171835 b363888ca5d88c11e67237ca4bc2c5c3cf1fcbdf
PiperOrigin-RevId: 599267642
2024-01-17 13:19:59 -08:00
alto-ruby
eaf1a92264 [Ruby] remove #include <sys/time.h> (#34178)
#34168

Closes #34178

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/34178 from alto-ruby:no-sys-time-h 42c5ad0f793893ec936cf90d6099abfeb82775ac
PiperOrigin-RevId: 590223092
2023-12-12 09:05:07 -08:00
Luwei Ge
dd12460018 [tls] Add set min/max TLS version APIs to TLS credentials APIs. (#34861)
Address #28382. This is a recreation of #31368 except e2e tests are not handled here (yet).

Closes #34861

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/34861 from rockspore:tls_version f9a1215ac1291722dba4f22cedc128c241aa3cab
PiperOrigin-RevId: 589847110
2023-12-11 09:27:44 -08:00
Mark D. Roth
15e2f9e873 [release] Bump version on master to 1.61.0-dev (#34923) 2023-11-13 08:33:46 -08:00
Adam Cozzette
016ed921ce [deps] Upgrade protobuf version to v25.0 (#34513)
This commit upgrades gRPC to protobuf v25.0 and makes some fixes to
account for upb changes. One major change is that upb has been merged
into the protobuf repo, so we can now drop the separate `@upb`
dependency. Another is that `.upb.c` files no longer exist and there are
new `.upb_minitable.h` and `.upb_minitable.c` files. The longer
filenames exceeded a Windows restriction, so to work around that I
renamed the `upb-generated` directory to just `upb-gen`, and likewise
for `upbdefs-generated`.
2023-11-10 00:11:09 -08:00
Matthew Stevenson
07985907f2 [tls] Fix ownership bugs in TlsCredentialsOptions and grpc_tls_credentials_options. (#34758)
Currently it is very easy to use the `TlsCredentialsOptions` in such a
way that it produces a memory leak. For example, the code block
```
{
  TlsCredentialsOptions options;
}
```
produces a memory leak. This PR fixes up the ownership bugs in this
class and its `grpc_tls_credentials_options`, the C-core analogue.
2023-10-27 08:09:04 -07:00
apolcyn
36af323673 [ruby] create debug symbol packages (#34632)
Introduce `grpc-native-debug` gems containing debug symbol packages that
complement the shared libraries shipped in pre-compiled binary gems.

src/ruby/nativedebug/README.md has details on usage.
2023-10-17 10:45:08 -07:00
Richard Belleville
3bdd972c4a [Release] Bump master version to 1.60 (gjallarhorn) (#34488)
<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
2023-09-26 13:10:20 -07:00
Stan Hu
b3467cdab4 [ruby] Fix linking errors on x86-darwin (#34134)
https://github.com/grpc/grpc/pull/33538 added `-weak_framework
CoreFoundation` in `DLDFLAGS` for only `arm64-darwin` builds, but the
issue reported in https://github.com/grpc/grpc/issues/33483 can also
happen on `x86-darwin` builds. This can happen if:

1. The Ruby interpreter is compiled without
`-Wl,-undefined,dynamic_lookup`.
2. This happens if the Ruby interpreter is built with XCode 14.0 to 14.2
(https://bugs.ruby-lang.org/issues/19005).

Simplify the logic and always include `-weak_framework CoreFoundation`
for macOS builds.
2023-09-21 21:23:11 -07:00
alto-ruby
dfa040f49f [Ruby] replace strdup with gpr_strdup (#34177)
grpc 1.57.0 crashes win ruby and alpine due to no `strdup` in musl libc.
This diff replace `strdup` with `grp_strdup`

```
Thread 1 "ruby" received signal SIGSEGV, Segmentation fault.
0x00000000000a4596 in ?? ()
(gdb) bt
#0  0x00000000000a4596 in ?? ()
#1  0x00007ffff14e298c in grpc_rb_channel_create_in_process_add_args_hash_cb (key=<optimized out>, val=<optimized out>, args_obj=<optimized out>) at rb_channel_args.c:84
#2  0x00007ffff7c2b9ea in hash_ar_foreach_iter (error=0, argp=140737488344784, value=<optimized out>, key=<optimized out>) at hash.c:1341
```

fixes #34044
closes #27995
2023-09-19 11:56:18 -07:00
Esun Kim
1a1124903c [Deps] Upgrade Protobuf and Upb to 24.x (#34123)
On top of https://github.com/grpc/grpc/pull/34120
2023-08-29 10:58:48 -07:00
Esun Kim
a90f30008d [Release] Bump version to 1.59.0-dev (on master branch) (#34144)
Change was created by the release automation script. See
go/grpc-release.
2023-08-23 15:53:32 -07:00
apolcyn
06d0a6c0fd [ruby] improve handling for recv_message op failures (#34016)
[ruby] improve handling for recv_message op failures (don't assume recv_message ops won't fail e.g. if the call was cancelled by the peer)
2023-08-10 12:25:29 -07:00
alto-ruby
f3419f8373 [Ruby] set metadata_sent after call success (#33998)
fixes #25373
2023-08-09 23:56:07 +00:00
alto-ruby
b4a39a2230 [Ruby] add special status msg interop test (#33990)
fixes #24176

```
./tools/run_tests/run_interop_tests.py -l ruby -s c++ --use_docker
No module named 'apiclient'
Seen --use_docker flag, will run interop tests under docker.

IMPORTANT: The changes you are testing need to be locally committed
because only the committed changes in the current branch will be
copied to the docker environment.
START: Building interop docker images.
PASSED: build_docker_ruby [time=479.4sec, retries=0:0]
PASSED: build_docker_c++ [time=686.0sec, retries=0:0]
SUCCESS: All docker images built successfully.
START: interop_server_c++
PASSED: cloud_to_cloud:ruby:c++_server:cancel_after_begin:tls [time=0.9sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:empty_unary:tls [time=1.0sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:empty_stream:tls [time=1.0sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:cancel_after_first_response:tls [time=1.0sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:ping_pong:tls [time=1.0sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:server_streaming:tls [time=1.0sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:client_streaming:tls [time=1.0sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:large_unary:tls [time=1.0sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:status_code_and_message:tls [time=0.8sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:unimplemented_method:tls [time=0.8sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:custom_metadata:tls [time=0.9sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:unimplemented_service:tls [time=0.8sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:client_compressed_streaming:tls [time=0.8sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:special_status_message:tls [time=0.8sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:client_compressed_unary:tls [time=0.8sec, retries=0:0]
PASSED: cloud_to_cloud:ruby:c++_server:timeout_on_sleeping_server:tls [time=1.8sec, retries=0:0]
SUCCESS: All tests passed
```
2023-08-09 16:52:39 -07:00
apolcyn
7c21997dba [ruby] remove unnecessary background thread startup wait logic that interferes with forking (#33805)
Alternative to https://github.com/grpc/grpc/pull/33804 - this takes the
approach in
https://github.com/grpc/grpc/pull/33804#issuecomment-1645792677

Fix https://github.com/grpc/grpc/issues/33802

cc @casperisfine
2023-07-24 15:17:54 -07:00
AJ Heller
42b0d01e68 [Release] Bump version to 1.58.0-dev (on master branch) (#33825)
Change was created by the release automation script. See go/grpc-release
2023-07-24 10:09:08 -07:00
apolcyn
3d9f2d8f77 [ruby] improve possible error message in postfork parent (#33791)
The case of `!grpc_ruby_initial_pid()` can be a *cause* of the second
case, `!grpc_ruby_initial_thread`, so check the pid first.
2023-07-20 13:47:13 -07:00
apolcyn
d4cbb7a96d [ruby] fix crash when prefork/postfork is used without previously using grpc (#33788)
Should fix https://github.com/grpc/grpc/issues/33787
2023-07-20 11:26:02 -07:00
apolcyn
a28900a9cf [ruby] raise RPC deadline in a flakey test (#33713)
As title - use a deadline that rules out starvation as a source of
flakiness
2023-07-20 10:07:24 -07:00
alto-ruby
75ecd170f8 [Ruby] remove manual strip in ruby ext conf (#33641)
Custom strip invalidates the signature, caused the arm64-darwin gem
failed to run on M1 macs.
Error in mac console: `Exception Type: EXC_BAD_ACCESS (SIGKILL (Code
Signature Invalid))`

Warning in gem build log:
```
# linking shared-object grpc/grpc_c.bundle
# Stripping grpc_c.bundle
# /opt/osxcross/target/bin/aarch64-apple-darwin20.2-strip: warning: changes being made to the file will invalidate the code signature in: /Users/jeff/work/ruby/grpc/tmp/arm64-darwin/grpc_c/3.2.0/grpc_c.bundle
```

Custom stripping is not really needed (any more), this diff removes it
from `src/ruby/ext/grpc/extconf.rb`, the [gem
artifact](https://console.cloud.google.com/storage/browser/grpc-testing-kokoro-prod/test_result_public/prod/grpc/core/pull_request/linux/grpc_distribtests_ruby/19833/20230708-181642/github/grpc/artifacts?pageState=(%22StorageObjectListTable%22:(%22f%22:%22%255B%255D%22))&prefix=&forceOnObjectsSortingFiltering=false)
size didn't change and arm64-darwin gem runs fine on M1 mac.

fixes: #28631
fixes: #29100
2023-07-17 16:57:45 -07:00
AJ Heller
c81bdf7a83 [Protobuf] Upgrade third_party/protobuf to 23.4 (#33695)
This was done manually due to a problem with
`tools/distrib/python/make_grpcio_tools.py`. ~I fixed it in this PR
(depends on cl/547979185), so there is a fair chance this upgrade will
work normally for the next release.~ The fix may be problematic for
upgrading protobuf on older release branches, so the improvement will be
worked on separately. CC @jtattermusch

This also updates the UPB dep to the latest commit on the 23.x branch.
2023-07-14 12:04:40 -07:00
apolcyn
b21152269d [ruby] simplify shutdown; remove unnecessary attempts at grpc_shutdown (#33674)
So far, we've structured global C-core init/shutdown as follows:
1) every grpc-ruby object calls `grpc_init` when allocated, and
`grpc_shutdown` when finalized
2) grpc-ruby background threads are each wrapped in a
`grpc_init/shutdown` pair - for example see
b32d94de05/src/ruby/ext/grpc/rb_event_thread.c (L122)
and
b32d94de05/src/ruby/ext/grpc/rb_event_thread.c (L136)

But because ruby doesn't join ruby threads when the process is
terminating, the `init/shutdown` pairs in 2) are always left open. I.e.,
thus far we have never been invoking the final call to `grpc_shutdown`
which actually does C-core global shutdown. Thus our calls to
`grpc_shutdown` are useless.

So we might as well keep things simple and not even attempt to call
`grpc_shutdown`. Now we just call `grpc_init` before using C-core, and
then never even attempt global shutdown (in non-forking situations).

As a bonus, this fixes the issue with the event thread's
`grpc_ruby_init` racing with `prefork` that is mentioned in
https://github.com/grpc/grpc/pull/33666
2023-07-12 15:50:33 -07:00
apolcyn
fe11ec9bcb [ruby] experimental client side fork support (#33430)
Adds experimental fork support to gRPC/Ruby

Works towards https://github.com/grpc/grpc/issues/8798 (see caveats for why this wasn't marked fixed yet)
Works towards https://github.com/grpc/grpc/issues/33578 (see caveats for why this wasn't marked fixed yet)

This leverages existing `pthread_atfork` based C-core support for
forking that python/php use, but there's a bit extra involved mainly
because gRPC/Ruby has additional background threads.

New tests under `src/ruby/end2end` show example usage.

Based on https://github.com/grpc/grpc/pull/33495

Caveats:
- Bidi streams are not yet supported (bidi streams spawn background
threads which are not yet fork safe)
- Servers not supported
- Only linux supported
2023-07-10 13:34:10 -07:00
alto-ruby
f7b1ed8287 [Ruby] remove objs and strip libs in ruby extension build (#33596)
Remove `src/ruby/ext/grpc/objs/` and strip `src/ruby/ext/grpc/libs/` in
ruby build dir to save some space.
This can reduce the grpc gem size from more than 1G to about 70~80M.
This only affects opt build, dbg build remains the same.

A proper fix maybe use the same makefile to build c-core and the
extension rather than building c-core when generating the extension
makefile.

fixes: https://github.com/grpc/grpc/issues/33412
2023-07-09 18:38:53 -07:00