You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can see above, when calling fmt.Sprintf() with job.Error is a nil dereference, it will reach /your_go_root/src/fmt/print.go::printArg(), in this case arg == nil is not true.
Finally, we got /your_go_rootc/src/fmt/print.go::handleMethods(), in this case v or p.arg is a nil dereference cause it's from job.Error, and it is an error type casue job.Error is a pointer of terror.Error, so error occurs when calling v.Error().
switch verb {
case 'v', 's', 'x', 'X', 'q':
switch v := p.arg.(type) {
case error:
handled = true
defer p.catchPanic(p.arg, verb, "Error")
p.fmtString(v.Error(), verb)
return
......
}
......
}
Here's a simple test case that you can re-produce the error in debug mode:
type ABC struct {
a int64
b bool
c *terror.Error
}
func TestSprintf(t *testing.T) {
abc := &ABC{c: nil}
s := fmt.Sprintf("Testing's Err: %v", abc.c)
println(s)
}
Bug Report
Debugging a test case in TiDB and stuck in debug mode, see error of 'bad access: nil dereference'
Here's an exactly case:
job.Error is a nil dereference
, it will reach /your_go_root/src/fmt/print.go::printArg(), in this casearg == nil
is not true.v or p.arg
is a nil dereference cause it's from job.Error, and it is an error type casue job.Error is a pointer of terror.Error, so error occurs when calling v.Error().Here's a simple test case that you can re-produce the error in debug mode:
No Errors
bad access: nil dereference
[email protected]
The text was updated successfully, but these errors were encountered: