wwbmmm opened a new pull request, #3500:
URL: https://github.com/apache/brpc/pull/3500
## What problem does this PR solve?
Problem Summary:
A bRPC Thrift client can be brought down by a peer reply that carries a
malformed `T_EXCEPTION`. The exception struct is decoded in
`ReadThriftException` without a try/catch; a bad field or an oversized
length makes the underlying thrift library throw (`TProtocolException`,
`TTransportException` or `std::length_error`). The exception is not caught
anywhere on the return path and eventually reaches the bthread task frame,
where `std::terminate()` is called, terminating the whole process.
This only affects builds with `WITH_THRIFT` enabled (off by default).
## What is changed and the side effects?
Changed:
`ReadThriftException` now wraps the decode of the exception struct in the
same `try/catch` that `ReadThriftStruct` already uses for the normal reply
body. A malformed `T_EXCEPTION` reply is reported as a failed RPC instead
of crashing the process.
Side effects:
- None. The fix only contains an otherwise-uncaught exception.
- Performance effects: none.
- Breaking backward compatibility: none.
## Check List
- [x] The change is compilable.
- [x] A unit test is added in `test/brpc_thrift_protocol_unittest.cpp`
that feeds a malformed `T_EXCEPTION` reply through the client
response path and asserts the call does not crash and marks the
controller failed.
- [x] Follows the Contributor Covenant Code of Conduct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]