Skip to content

cleanup: Fix clang-tidy for performance-unnecessary-value-param#1057

Closed
rlazarus wants to merge 1 commit intoenvoyproxy:masterfrom
rlazarus:tidy-value-param
Closed

cleanup: Fix clang-tidy for performance-unnecessary-value-param#1057
rlazarus wants to merge 1 commit intoenvoyproxy:masterfrom
rlazarus:tidy-value-param

Conversation

@rlazarus
Copy link
Copy Markdown
Contributor

@rlazarus rlazarus commented 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 #1024, but now without changing the HostSharedPtr argument to HealthCheckerImplBase::runCallbacks() -- as @dnoe points out, that copy is necessary for reference counting, and that's why #1024 broke asan/tsan.

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.
@mattklein123
Copy link
Copy Markdown
Member

@rlazarus presumably you used some automated tool to do this. How did you indicate that something that was changed before should not be changed? In general passing shared pointers by reference is dangerous (as we saw here) and it makes me uneasy that the tool might be doing things we don't fully understand.

@mattklein123
Copy link
Copy Markdown
Member

@rlazarus I'm going to close this for now. Let's reopen when we have some clarity on the ownership issue that was causing problems.

jpsim pushed a commit that referenced this pull request Nov 28, 2022
In the case when the JVM calls a native method, the native method will automatically handle local references within the method upon a the method's return.

However, in the case where the native method calls a JVM method, local references created will not be deleted after the method returns. In some of these cases, we have forgotten to clean up some of these local references prior to returning.

While we previously did not do this clean up for `on_error` and `on_cancel` and since these were rarer events, we did not observe any issues. However, with the introduction of platform based filters, we also did not clean this up for the filter initialization which does occur more often and we ran into issues.

Signed-off-by: Alan Chiu <achiu@lyft.com>

For an explanation of how to fill out the fields, please see the relevant section
in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/master/PULL_REQUESTS.md)

Description: jni: fix unreleased local refs
Risk Level: low
Testing: ci
Docs Changes: na
Release Notes: na
[Optional Fixes #Issue]
[Optional Deprecated:]

Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
In the case when the JVM calls a native method, the native method will automatically handle local references within the method upon a the method's return.

However, in the case where the native method calls a JVM method, local references created will not be deleted after the method returns. In some of these cases, we have forgotten to clean up some of these local references prior to returning.

While we previously did not do this clean up for `on_error` and `on_cancel` and since these were rarer events, we did not observe any issues. However, with the introduction of platform based filters, we also did not clean this up for the filter initialization which does occur more often and we ran into issues.

Signed-off-by: Alan Chiu <achiu@lyft.com>

For an explanation of how to fill out the fields, please see the relevant section
in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/master/PULL_REQUESTS.md)

Description: jni: fix unreleased local refs
Risk Level: low
Testing: ci
Docs Changes: na
Release Notes: na
[Optional Fixes #Issue]
[Optional Deprecated:]

Signed-off-by: JP Simard <jp@jpsim.com>
mathetake pushed a commit that referenced this pull request Mar 3, 2026
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.

2 participants