Skip to content

Cleanup: Fix clang-tidy for performance-unnecessary-value-param#1024

Closed
rlazarus wants to merge 2 commits intoenvoyproxy:masterfrom
rlazarus:tidy-value-param
Closed

Cleanup: Fix clang-tidy for performance-unnecessary-value-param#1024
rlazarus wants to merge 2 commits intoenvoyproxy:masterfrom
rlazarus:tidy-value-param

Conversation

@rlazarus
Copy link
Copy Markdown
Contributor

Wherever safe, avoid unnecessary expensive copies due to value-typed function parameters, either by making them const references or by using std::move. See http://clang.llvm.org/extra/clang-tidy/checks/performance-unnecessary-value-param.html for details.

Wherever safe, avoid unnecessary expensive copies due to value-typed
function parameters, either by making them const references or by using
`std::move`. See
http://clang.llvm.org/extra/clang-tidy/checks/performance-unnecessary-value-param.html
for details.
htuch
htuch previously approved these changes May 26, 2017
Copy link
Copy Markdown
Member

@RomanDzhabarov RomanDzhabarov left a comment

Choose a reason for hiding this comment

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

very nice!

@RomanDzhabarov
Copy link
Copy Markdown
Member

oops, looks like one test is failing ;)

@rlazarus
Copy link
Copy Markdown
Contributor Author

Don't merge -- asan/tsan are failing, so it's possible one of these changes wasn't actually as safe as it looked. Trying to sort that out.

@RomanDzhabarov
Copy link
Copy Markdown
Member

yup, was not going to merge...

@rlazarus
Copy link
Copy Markdown
Contributor Author

Unfortunately I'm heading out on vacation -- I was hoping to have this figured out by the end of today, but here we are. I'll be back on Thursday, but I'm going to close the PR while I'm OOO since it's hardly urgent. I'll open a fresh one once I figure out why this breaks asan and tsan. (Or, if someone else sees it, feel free to fix in my absence -- just let me know, because I'm curious!)

@rlazarus rlazarus closed this May 26, 2017
~MockDetector();

void runCallbacks(HostSharedPtr host) {
void runCallbacks(const HostSharedPtr& host) {
Copy link
Copy Markdown
Contributor

@dnoe dnoe May 30, 2017

Choose a reason for hiding this comment

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

This is the troublesome line. By using a reference here the "host" variable refers back to what's passed into runCallbacks in sds_test.cc:244 rather than making a shared_ptr copy and thus reference count increase. One of the callbacks modifies the host list returned by cluster_->hosts(), with this change the reference count indicates it is safe to free the host when the host list is updated. The callback itself DOES use pass-by-value function argument, so when it returns the HostSharedPtr goes out of scope resulting in a read of the reference count (but the object has already been deleted).

It can be const, but not a reference.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Aha! Thanks for tracking that down.

rlazarus pushed a commit to rlazarus/envoy that referenced this pull request Jun 6, 2017
Wherever safe, avoid unnecessary expensive copies due to value-typed
function parameters, either by making them const references or by using
std::move. See
http://clang.llvm.org/extra/clang-tidy/checks/performance-unnecessary-value-param.html
for details.

This is the same tool that I ran in envoyproxy#1024, but without touching
HealthCheckerImplBase::runCallbacks: as @dpn points out, that copy is
necessary for reference counting, and that's why envoyproxy#1024 broke asan/tsan.
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: Adds unit-level coverage to the JvmBridgeUtility.

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: Adds unit-level coverage to the JvmBridgeUtility.

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
mathetake pushed a commit that referenced this pull request Mar 3, 2026
**Description**
This PR add error response handling for GCP Gemini models. It converts
error message from GCP Gemini format to openai api format

**Related Issues/PRs (if applicable)**
Issue: envoyproxy/ai-gateway#609

---------

Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants