[
https://issues.apache.org/jira/browse/MINIFICPP-513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16493794#comment-16493794
]
ASF GitHub Bot commented on MINIFICPP-513:
------------------------------------------
Github user phrocker commented on a diff in the pull request:
https://github.com/apache/nifi-minifi-cpp/pull/346#discussion_r191487153
--- Diff: libminifi/src/controllers/NetworkPrioritizerService.cpp ---
@@ -65,33 +65,38 @@ void NetworkPrioritizerService::yield() {
/**
* If not an intersecting operation we will attempt to locate the highest
priority interface available.
*/
-io::NetworkInterface &&NetworkPrioritizerService::getInterface(uint32_t
size = 0) {
+io::NetworkInterface NetworkPrioritizerService::getInterface(uint32_t size
= 0) {
std::vector<std::string> controllers;
+ std::string ifc = "";
if (!network_controllers_.empty()) {
if (sufficient_tokens(size) && size < max_payload_) {
controllers.insert(std::end(controllers),
std::begin(network_controllers_), std::end(network_controllers_));
}
}
if (!controllers.empty()) {
- auto ifc = get_nearest_interface(controllers);
+ ifc = get_nearest_interface(controllers);
if (!ifc.empty()) {
reduce_tokens(size);
- return std::move(io::NetworkInterface(ifc, shared_from_this()));
+ io::NetworkInterface newifc(ifc, shared_from_this());
+ return newifc;
--- End diff --
That caused issue on one distro I tested in regards to the transient
string. the string was being elided causing an access an error later. In this
case the optimization didn't happen. It seems to be specific to that U18
compiler, so I took this route and this avoided the problem with valgrind
verification.
> RVO causing seg fault due to taking reference to transient
> -----------------------------------------------------------
>
> Key: MINIFICPP-513
> URL: https://issues.apache.org/jira/browse/MINIFICPP-513
> Project: NiFi MiNiFi C++
> Issue Type: Bug
> Reporter: marco polo
> Assignee: marco polo
> Priority: Major
>
> RVO causing seg fault due to taking reference to transient on certain
> compilers. Additionally, during profiling found that elision was prevented,
> so we should avoid using the rvalue reference for the return and move
> semantics and let the compiler take care of the optimization.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)