Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext_proc filter crash when sending trailers when request has no body #27430

Merged
merged 3 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion source/extensions/filters/http/ext_proc/ext_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ class Filter : public Logger::Loggable<Logger::Id::ext_proc>,

void sendBufferedData(ProcessorState& state, ProcessorState::CallbackState new_state,
bool end_stream) {
sendBodyChunk(state, *state.bufferedData(), new_state, end_stream);
if (state.hasBufferedData()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert on ext-proc, so high-level observation.
IIUC the current fix prevents sending a body of length 0 with end_stream. If this is the desired behavior, then I think it is ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments!
Actually, ext_proc filter supports sending a body of length 0:

TEST_P(ExtProcIntegrationTest, BufferBodyOverridePostWithEmptyBody) {

This change is causing test failures. So, we changed it into if the no buffered data, then sends an empty body.

After that, we seeing another issue with stream_ pointer as null, so the new change also fixed it. Please check the root cause comments for details.

sendBodyChunk(state, *state.bufferedData(), new_state, end_stream);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another observation: the call in case of an empty body, will not change the state to new_state. Is this the desired outcome?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good catch. We should send an empty body if no buffered data as in the new diffs.

}
}
void sendBodyChunk(ProcessorState& state, const Buffer::Instance& data,
ProcessorState::CallbackState new_state, bool end_stream);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.