Skip to content

Commit

Permalink
Fix msan errors (#22641)
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Avlasov <[email protected]>
  • Loading branch information
yanavlasov authored Aug 10, 2022
1 parent ff11af7 commit 9e7fba8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
24 changes: 12 additions & 12 deletions source/common/stats/allocator_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,6 @@ class AllocatorImpl : public Allocator {
StatSet<Gauge> gauges_ ABSL_GUARDED_BY(mutex_);
StatSet<TextReadout> text_readouts_ ABSL_GUARDED_BY(mutex_);

// Retain storage for deleted stats; these are no longer in maps because
// the matcher-pattern was established after they were created. Since the
// stats are held by reference in code that expects them to be there, we
// can't actually delete the stats.
//
// It seems like it would be better to have each client that expects a stat
// to exist to hold it as (e.g.) a CounterSharedPtr rather than a Counter&
// but that would be fairly complex to change.
std::vector<CounterSharedPtr> deleted_counters_ ABSL_GUARDED_BY(mutex_);
std::vector<GaugeSharedPtr> deleted_gauges_ ABSL_GUARDED_BY(mutex_);
std::vector<TextReadoutSharedPtr> deleted_text_readouts_ ABSL_GUARDED_BY(mutex_);

template <typename StatType> using StatPointerSet = absl::flat_hash_set<StatType*>;
// Stat pointers that participate in the flush to sink process.
StatPointerSet<Counter> sinked_counters_ ABSL_GUARDED_BY(mutex_);
Expand All @@ -107,6 +95,18 @@ class AllocatorImpl : public Allocator {
SymbolTable& symbol_table_;

Thread::ThreadSynchronizer sync_;

// Retain storage for deleted stats; these are no longer in maps because
// the matcher-pattern was established after they were created. Since the
// stats are held by reference in code that expects them to be there, we
// can't actually delete the stats.
//
// It seems like it would be better to have each client that expects a stat
// to exist to hold it as (e.g.) a CounterSharedPtr rather than a Counter&
// but that would be fairly complex to change.
std::vector<CounterSharedPtr> deleted_counters_ ABSL_GUARDED_BY(mutex_);
std::vector<GaugeSharedPtr> deleted_gauges_ ABSL_GUARDED_BY(mutex_);
std::vector<TextReadoutSharedPtr> deleted_text_readouts_ ABSL_GUARDED_BY(mutex_);
};

} // namespace Stats
Expand Down
3 changes: 2 additions & 1 deletion source/extensions/filters/udp/dns_filter/dns_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ class DnsQueryContext {
uint16_t response_code_;
uint64_t retry_;
uint16_t id_;
Network::DnsResolver::ResolutionStatus resolution_status_;
Network::DnsResolver::ResolutionStatus resolution_status_ =
Network::DnsResolver::ResolutionStatus::Success;
DnsHeader header_;
DnsHeader response_header_;
DnsQueryPtrVec queries_;
Expand Down
8 changes: 3 additions & 5 deletions test/integration/fake_resource_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

namespace Envoy {

FakeResourceMonitor::~FakeResourceMonitor() { factory_.onMonitorDestroyed(this); }
FakeResourceMonitor::~FakeResourceMonitor() { factory_.onMonitorDestroyed(); }

void FakeResourceMonitor::updateResourceUsage(Server::ResourceUpdateCallbacks& callbacks) {
Server::ResourceUsage usage;
usage.resource_pressure_ = pressure_;
callbacks.onSuccess(usage);
}

void FakeResourceMonitorFactory::onMonitorDestroyed(FakeResourceMonitor* monitor) {
ASSERT(monitor_ == monitor);
monitor_ = nullptr;
}
void FakeResourceMonitorFactory::onMonitorDestroyed() { monitor_ = nullptr; }

Server::ResourceMonitorPtr FakeResourceMonitorFactory::createResourceMonitor(
const Protobuf::Message&, Server::Configuration::ResourceMonitorFactoryContext& context) {
auto monitor = std::make_unique<FakeResourceMonitor>(context.mainThreadDispatcher(), *this);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/fake_resource_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FakeResourceMonitorFactory : public Server::Configuration::ResourceMonitor
}

FakeResourceMonitor* monitor() const { return monitor_; }
void onMonitorDestroyed(FakeResourceMonitor* monitor);
void onMonitorDestroyed();

private:
FakeResourceMonitor* monitor_{nullptr};
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/stream_info/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MockUpstreamInfo : public UpstreamInfo {
std::string failure_reason_;
Upstream::HostDescriptionConstSharedPtr upstream_host_;
FilterStateSharedPtr filter_state_;
uint64_t num_streams_;
uint64_t num_streams_ = 0;
absl::optional<Http::Protocol> upstream_protocol_;
};

Expand Down

0 comments on commit 9e7fba8

Please sign in to comment.