是什么导致fmt.Sprintf中的此引用指针出现紧急情况

问题描述

当我在生产环境中使用fmt.Sprintf格式化字符串对象时,偶尔会出现如下恐慌:

  var finalObject=[{ "key1": true,"header": "Title A","Size": 100},{ "key1": true,"header": "Title1","header": "Title2","Size": 100}....]

相对代码是:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x469772]

goroutine 225594643 [running]:
fmt.(*buffer).writeString(...)
        /home/compile/makepkg_go/go/src/fmt/print.go:82
fmt.(*fmt).padString(0xc000112c70,0x0,0x7)
        /home/compile/makepkg_go/go/src/fmt/format.go:110 +0x8c
fmt.(*fmt).fmtS(0xc000112c70,0x7)
        /home/compile/makepkg_go/go/src/fmt/format.go:359 +0x61
fmt.(*pp).fmtString(0xc000112c30,0x7,0x73)
        /home/compile/makepkg_go/go/src/fmt/print.go:450 +0x1ba
fmt.(*pp).printArg(0xc000112c30,0x9b4360,0xc00193a930,0x73)
        /home/compile/makepkg_go/go/src/fmt/print.go:698 +0x843
fmt.(*pp).doPrintf(0xc000112c30,0xaa4b6c,0x1a,0xc00169deb8,0x9,0x9)
        /home/compile/makepkg_go/go/src/fmt/print.go:1030 +0x15a
fmt.Sprintf(0xaa4b6c,0xc001edced0,0xa)
        /home/compile/makepkg_go/go/src/fmt/print.go:219 +0x66
code.aliyun.com/re-audio/engines/simplestatisticengine.AudioCountRun(0xc001ca7a00,0x14,0xa9
8fec,0xa,0xa98dd0,0xc0018e329b,0x5,...)
        /home/compile/makepkg/re-audio/engines/simplestatisticengine/sse.go:253 +0x384
created by code.aliyun.com/re-audio/audioprocessor.(*AudioClips).clipsstatistic
        /home/compile/makepkg/re-audio/audioprocessor/audio-clips.go:549 +0x3a0

这个问题很难重复。我猜AudioCountRun中的“ appId”参数有问题。不确定appId的类型正确,但是其数据错误。 我应该朝哪个方向寻找这个问题的原因?

解决方法

应该看到此问题https://github.com/golang/go/issues/39587

程序中audioMapNamekey上存在数据争用