-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Update gutil_dump.go #2305
Update gutil_dump.go #2305
Conversation
Solve the panic: reflect: call of reflect.Value.Type on zero Value [recovered] The reason for this is the circular reference itself
it likes
output: |
@@ -110,9 +110,12 @@ func doDump(value interface{}, indent string, buffer *bytes.Buffer, option doDum | |||
} | |||
var ( | |||
reflectKind = reflectValue.Kind() | |||
reflectTypeName = reflectValue.Type().String() | |||
reflectTypeName = "invalid" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may check the reflectValue at line 107:
// Double check nil value.
if value == nil || reflectValue.IsNil() || !reflectValue.IsValid() {
buffer.WriteString(`<nil>`)
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried your way of checking the reflectValue, and it brings the same mistake.
Not available to check reflectValue with IsNil().
The method I submitted is available.
I apologize for my poor English.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brick-carrier-fan OK, then try this:
// Double check nil value.
if value == nil || !reflectValue.IsValid() || (reflectValue.Kind() == reflect.Ptr && reflectValue.IsNil()) {
buffer.WriteString(`<nil>`)
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,buffer will go to get infinitely bigger,then get OOM panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,buffer will go to get infinitely bigger,then get OOM panic
Any question carrying on this PR?
@brick-carrier-fan Please add UT case for this issue, too. |
Codecov ReportBase: 78.17% // Head: 78.15% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #2305 +/- ##
==========================================
- Coverage 78.17% 78.15% -0.02%
==========================================
Files 584 584
Lines 48535 48538 +3
==========================================
- Hits 37942 37937 -5
- Misses 8579 8584 +5
- Partials 2014 2017 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -110,9 +110,12 @@ func doDump(value interface{}, indent string, buffer *bytes.Buffer, option doDum | |||
} | |||
var ( | |||
reflectKind = reflectValue.Kind() | |||
reflectTypeName = reflectValue.Type().String() | |||
reflectTypeName = "invalid" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brick-carrier-fan OK, then try this:
// Double check nil value.
if value == nil || !reflectValue.IsValid() || (reflectValue.Kind() == reflect.Ptr && reflectValue.IsNil()) {
buffer.WriteString(`<nil>`)
return
}
@@ -110,9 +110,12 @@ func doDump(value interface{}, indent string, buffer *bytes.Buffer, option doDum | |||
} | |||
var ( | |||
reflectKind = reflectValue.Kind() | |||
reflectTypeName = reflectValue.Type().String() | |||
reflectTypeName = "invalid" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,buffer will go to get infinitely bigger,then get OOM panic
Any question carrying on this PR?
@brick-carrier-fan I fix this in #2367 |
Solve the panic: reflect: call of reflect.Value.Type on zero Value [recovered] The reason for this is the circular reference itself