-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Possible panic: nil pointer dereference
#5981
Comments
If this is an issue, I’m willing to create a PR to fix it. |
Hey there, @ldlb9527! I'm here to help you with any bugs, questions, or contributions you have. Let's work together to solve any issues you encounter. To prevent a null pointer dereference in the Jaeger var traces []*model.Trace
var trace *model.Trace
var traceID model.TraceID
for received, err := stream.Recv(); !errors.Is(err, io.EOF); received, err = stream.Recv() {
if err != nil {
return nil, fmt.Errorf("stream error: %w", err)
}
for i, span := range received.Spans {
if span.TraceID.IsZero() {
continue // Skip spans with zero TraceID
}
if span.TraceID != traceID {
trace = &model.Trace{}
traceID = span.TraceID
traces = append(traces, trace)
}
trace.Spans = append(trace.Spans, &received.Spans[i])
}
} In this code, the It looks like this issue needs your expertise, @yurishkuro, could you take a look? |
Signed-off-by: vaidikcode <[email protected]> ## Which problem is this PR solving? - Resolves #5981 ## Description of the changes - This will cause a null pointer exception if trace is appended without the if block being executed. ## How was this change tested? - ## Checklist - [ ] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [ ] I have signed all commits - [ ] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` Co-authored-by: Yuri Shkuro <[email protected]>
What happened?
The following code will cause a null pointer exception on the first iteration of the loop if
span.TraceID
has a zero value.Steps to reproduce
https://github.com/jaegertracing/jaeger/blob/main/plugin/storage/grpc/shared/grpc_client.go#L193-L209
The text was updated successfully, but these errors were encountered: