From 31d48a58ec483a67b0623c827df84dfb03f6e34b Mon Sep 17 00:00:00 2001 From: bryan-aguilar <46550959+bryan-aguilar@users.noreply.github.com> Date: Mon, 20 Feb 2023 18:05:17 -0800 Subject: [PATCH] [receiver/awsecscontainermetricsreceiver] Fix possible sigsegv in shutdown (#18736) Fix possible sigsev error that could occur during shutdown if component was not correctly initialized. Link to tracking Issue: Reported in ADOT downstream repository aws-observability/aws-otel-collector#982 (comment) --- .chloggen/ecsCMshutdown.yaml | 16 ++++++++++++++++ .../awsecscontainermetricsreceiver/receiver.go | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 .chloggen/ecsCMshutdown.yaml diff --git a/.chloggen/ecsCMshutdown.yaml b/.chloggen/ecsCMshutdown.yaml new file mode 100755 index 000000000000..f4bbbc4bd024 --- /dev/null +++ b/.chloggen/ecsCMshutdown.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: awsecscontainermetricsreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Fix possible sig sev that could happen during component shutdown. + +# One or more tracking issues related to the change +issues: [18736] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/receiver/awsecscontainermetricsreceiver/receiver.go b/receiver/awsecscontainermetricsreceiver/receiver.go index 76b4a488889f..8cf033176276 100644 --- a/receiver/awsecscontainermetricsreceiver/receiver.go +++ b/receiver/awsecscontainermetricsreceiver/receiver.go @@ -79,7 +79,9 @@ func (aecmr *awsEcsContainerMetricsReceiver) Start(ctx context.Context, host com // Shutdown stops the awsecscontainermetricsreceiver receiver. func (aecmr *awsEcsContainerMetricsReceiver) Shutdown(context.Context) error { - aecmr.cancel() + if aecmr.cancel != nil { + aecmr.cancel() + } return nil }