Skip to content

Commit 8a06db3

Browse files
committed
Fix missing early return in error's update tracing attributes method and UB in host name parcing
commit_hash:cc382538d686689db47047d08624b01ac8893464
1 parent df54692 commit 8a06db3

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

yt/yt/core/misc/error.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ void TryExtractHost(const TOriginAttributes& attributes)
6969
spanId
7070
] = Decode(*attributes.ExtensionData);
7171

72-
attributes.Host = name;
72+
attributes.Host = name
73+
? TStringBuf(name)
74+
: TStringBuf{};
7375
}
7476

7577
////////////////////////////////////////////////////////////////////////////////
@@ -125,6 +127,7 @@ void UpdateTracingAttributes(TOriginAttributes* attributes, const NTracing::TTra
125127
.TraceId = tracingAttributes.TraceId,
126128
.SpanId = tracingAttributes.SpanId,
127129
}));
130+
return;
128131
}
129132

130133
attributes->ExtensionData.emplace(Encode(TExtensionData{

yt/yt/core/misc/stripped_error.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,21 @@ void AppendError(TStringBuilderBase* builder, const TError& error, int indent)
797797

798798
for (const auto& [key, value] : error.Attributes().ListPairs()) {
799799
TTokenizer tokenizer(value.AsStringBuf());
800-
YT_VERIFY(tokenizer.ParseNext());
800+
// TODO(arkady-e1ppa): Remove this once failed verifies have been dealt with.
801+
[[unlikely]] if (!tokenizer.ParseNext()) {
802+
Cerr <<
803+
NYT::Format(
804+
"%v *** Empty toke encountered while formatting TError attribute (Key: %v, Value: %v"
805+
"(BuilderAccumulatedData: %v)",
806+
TInstant::Now(),
807+
key,
808+
value.AsStringBuf(),
809+
builder->GetBuffer())
810+
<< '\n';
811+
Flush(Cerr);
812+
YT_ABORT();
813+
}
814+
// YT_VERIFY(tokenizer.ParseNext());
801815
switch (tokenizer.GetCurrentType()) {
802816
case ETokenType::String:
803817
AppendAttribute(builder, key, TString(tokenizer.CurrentToken().GetStringValue()), indent);

0 commit comments

Comments
 (0)