mirror of https://github.com/grpc/grpc.git
[Python Otel] Fix Segfault caused by CallTracer method lifetime issue (#37329)
We're seeing a segfault issue in observability tests: ``` 2024-07-26T09:09:18.422255153Z *** SIGSEGV received at time=1721984958 on cpu 0 *** 2024-07-26T09:09:18.424985750Z PC: @ 0x7e1acccb71c9 (unknown) (unknown) 2024-07-26T09:09:18.425333774Z @ 0x7e1ac714ed8c 64 absl::lts_20240116::WriteFailureInfo() 2024-07-26T09:09:18.425356717Z @ 0x7e1ac714ea15 272 absl::lts_20240116::AbslFailureSignalHandler() 2024-07-26T09:09:18.425368880Z @ 0x7e1accb98050 1584 (unknown) 2024-07-26T09:09:18.426117382Z @ 0x7e1ac77f458c 112 absl::lts_20240116::string_view::operator std::__cxx11::basic_string<><>() 2024-07-26T09:09:18.426647368Z @ 0x7e1ac78008df 688 grpc_observability::PythonOpenCensusCallTracer::PythonOpenCensusCallAttemptTracer::RecordEnd() ``` It points to `absl::string_view::operator std::__cxx11::basic_string<>()` which indicates the issue might be related to string conversion. The most probable cause is that the `parent_->method_` string object is being destroyed before the `std::string` conversion is completed or used by `emplace_back`:pull/37335/headb056bc41d3/src/python/grpcio_observability/grpc_observability/client_call_tracer.cc (L325-L326)
Since it's difficult to manage the lifecycle of `method` in Python/Cython, this PR changes `method_` and `traget_` from `absl::string_view` to `std::string` so that they'll always be available. <!-- 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 #37329 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37329 from XuanWang-Amos:fix_otel_segfaultc579022529
PiperOrigin-RevId: 657366034
parent
b056bc41d3
commit
b6e0137608
3 changed files with 11 additions and 14 deletions
Loading…
Reference in new issue