提交 40b48213 编写于 作者: A aarzilli 提交者: Alessandro Arzilli

proc/variables: protect form invalid G struct in parseG

A waitreason string that has invalid length (because the G struct is
corrupted or being modified) could cause a crash.
上级 53908019
......@@ -546,6 +546,9 @@ func TestNextConcurrentVariant2(t *testing.T) {
var vval int64
for {
v, err := evalVariable(p, "n")
for _, thread := range p.ThreadList() {
proc.GetG(thread)
}
assertNoError(err, t, "EvalVariable")
vval, _ = constant.Int64Val(v.Value)
if bp, _, _ := p.CurrentThread().Breakpoint(); bp == nil {
......
......@@ -380,7 +380,10 @@ func (gvar *Variable) parseG() (*G, error) {
sp, _ := constant.Int64Val(schedVar.fieldVariable("sp").Value)
id, _ := constant.Int64Val(gvar.fieldVariable("goid").Value)
gopc, _ := constant.Int64Val(gvar.fieldVariable("gopc").Value)
waitReason := constant.StringVal(gvar.fieldVariable("waitreason").Value)
waitReason := ""
if wrvar := gvar.fieldVariable("waitreason"); wrvar.Value != nil {
waitReason = constant.StringVal(wrvar.Value)
}
var stackhi uint64
if stackVar := gvar.fieldVariable("stack"); stackVar != nil {
if stackhiVar := stackVar.fieldVariable("hi"); stackhiVar != nil {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册