envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.9k stars 4.79k forks source link

Function is executed twice by passing to macro RETURN_IF_NOT_OK #36697

Open congrab opened 2 days ago

congrab commented 2 days ago

In the invocation of the macro RETURN_IF_NOT_OK in the following code snippet, extracted from envoy/source/common/common/callback_impl.h:52

    for (auto it = callbacks_.cbegin(); it != callbacks_.cend();) {
      auto current = *(it++);
      RETURN_IF_NOT_OK(current->cb_(args...));
    }
    return absl::OkStatus();
  }

it expands to

    for (auto it = callbacks_.cbegin(); it != callbacks_.cend();) {
      auto current = *(it++);
      if(!current->cb_(args...).ok()) {
        return current->cb_(args...); // ---> POTENTIAL BUG here
      }
    }
    return absl::OkStatus();
  }

the statement current->cb_(args...); in invoked twice may lead to potential bug.

mkauf commented 2 days ago

This bug has already been fixed by #35482.

congrab commented 2 days ago

thank @mkauf , but I see this in v1.31.2. the change should be back ported to the previous releases, right? it has been fixed quite a long time ago.

mkauf commented 20 hours ago

@congrab

the change should be back ported to the previous releases, right?

Only nominated and approved fixes will be backported. See Backports in RELEASES.md.