diff options
| author | arkady-e1ppa <[email protected]> | 2024-10-08 20:49:02 +0300 |
|---|---|---|
| committer | arkady-e1ppa <[email protected]> | 2024-10-08 20:58:54 +0300 |
| commit | 8a06db32ead073cffc76465c8a703d0c9bfd06d7 (patch) | |
| tree | d775d2dc9a63bf24ff5f8afb1b97add7f3caddbb | |
| parent | df546929f65b5f89997eeb0f48d1665c07877b4b (diff) | |
Fix missing early return in error's update tracing attributes method and UB in host name parcing
commit_hash:cc382538d686689db47047d08624b01ac8893464
| -rw-r--r-- | yt/yt/core/misc/error.cpp | 5 | ||||
| -rw-r--r-- | yt/yt/core/misc/stripped_error.cpp | 16 |
2 files changed, 19 insertions, 2 deletions
diff --git a/yt/yt/core/misc/error.cpp b/yt/yt/core/misc/error.cpp index 8aff91e407b..950a7a0f022 100644 --- a/yt/yt/core/misc/error.cpp +++ b/yt/yt/core/misc/error.cpp @@ -69,7 +69,9 @@ void TryExtractHost(const TOriginAttributes& attributes) spanId ] = Decode(*attributes.ExtensionData); - attributes.Host = name; + attributes.Host = name + ? TStringBuf(name) + : TStringBuf{}; } //////////////////////////////////////////////////////////////////////////////// @@ -125,6 +127,7 @@ void UpdateTracingAttributes(TOriginAttributes* attributes, const NTracing::TTra .TraceId = tracingAttributes.TraceId, .SpanId = tracingAttributes.SpanId, })); + return; } attributes->ExtensionData.emplace(Encode(TExtensionData{ diff --git a/yt/yt/core/misc/stripped_error.cpp b/yt/yt/core/misc/stripped_error.cpp index c636ce9ce95..3406f61dac8 100644 --- a/yt/yt/core/misc/stripped_error.cpp +++ b/yt/yt/core/misc/stripped_error.cpp @@ -797,7 +797,21 @@ void AppendError(TStringBuilderBase* builder, const TError& error, int indent) for (const auto& [key, value] : error.Attributes().ListPairs()) { TTokenizer tokenizer(value.AsStringBuf()); - YT_VERIFY(tokenizer.ParseNext()); + // TODO(arkady-e1ppa): Remove this once failed verifies have been dealt with. + [[unlikely]] if (!tokenizer.ParseNext()) { + Cerr << + NYT::Format( + "%v *** Empty toke encountered while formatting TError attribute (Key: %v, Value: %v" + "(BuilderAccumulatedData: %v)", + TInstant::Now(), + key, + value.AsStringBuf(), + builder->GetBuffer()) + << '\n'; + Flush(Cerr); + YT_ABORT(); + } + // YT_VERIFY(tokenizer.ParseNext()); switch (tokenizer.GetCurrentType()) { case ETokenType::String: AppendAttribute(builder, key, TString(tokenizer.CurrentToken().GetStringValue()), indent); |
