Go 什么会偶尔导致fmt.Sprintf中的引用指针死机

Go 什么会偶尔导致fmt.Sprintf中的引用指针死机,go,panic,Go,Panic,当我在生产环境中使用fmt.Sprintf格式化字符串对象时,它偶尔会出现如下情况: 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(...)

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

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, 0x0, 0x7)
        /home/compile/makepkg_go/go/src/fmt/format.go:359 +0x61
fmt.(*pp).fmtString(0xc000112c30, 0x0, 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, 0x1a, 0xc00169deb8, 0x9, 0x9, 0xc001edced0, 0xa)
        /home/compile/makepkg_go/go/src/fmt/print.go:219 +0x66
code.aliyun.com/re-audio/engines/simplestatisticengine.AudioCountRun(0xc001ca7a00, 0x14, 0x0, 0x7, 0xa9
8fec, 0xa, 0xa98dd0, 0xa, 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
相关代码为:

    func AudioCountRun(
        organization, appId, serviceId,
        pattern, channel, soundproperty string, riskType int,
        riskLevel, reqId string) {
        if len(organization) == 0 || len(appId) == 0 || len(serviceId) == 0 || len(pattern) == 0 || len(channel) == 0 || len(soundproperty) == 0 || riskType < 0 || len(riskLevel) == 0 {
            return
        }
        if serviceId != "POST_AUDIO" {
            return
        }
        curTime := time.Now().Format(layout)
        key := fmt.Sprintf("%s@%s@%s@%s@%s@%s@%s@%d@%s",
            curTime, organization, appId,
            serviceId, pattern, channel,
            soundproperty, riskType, riskLevel)
        batchstatistic.Add(audioMapName, key, 1)
        ilog.LogReq(ilog.LL_INFO, "SimpleStatisticEngine.AudioCountRun.Add", reqId, fmt.Sprintf("(audioMapName=%s,key=%s)", audioMapName, key))
    }
func AudioCountRun(
组织、appId、serviceId、,
模式、频道、soundproperty字符串、riskType int、,
风险级别,请求ID字符串){
如果len(组织)=0 | | len(appId)=0 | | len(serviceId)=0 | | len(模式)==0 | | len(频道)==0 | | len(声音属性)==0 | | riskType<0 | | len riskLevel=0{
返回
}
如果serviceId!=“POST_音频”{
返回
}
curTime:=time.Now().格式(布局)
键:=fmt.Sprintf(“%s@%s@%s@%s@%s@%s@%s@%s@%d@%s”,
curTime,组织,应用程序ID,
服务ID、模式、通道、,
soundproperty、riskType、riskLevel)
batchstatistic.Add(audioMapName,键,1)
ilog.LogReq(ilog.LL_INFO,“SimpleStatisticEngine.AudioCountRun.Add”,请求ID,fmt.Sprintf(((audioMapName=%s,key=%s)”,audioMapName,key))
}
这个问题很难重复。我猜AudioCountRun中的“appId”参数有问题。不确定的是,appId的类型是正确的,但它的数据是错误的。 我应该从哪个方向查找此问题的原因?

应该看到此问题


程序中的
audioMapName
key
上存在数据竞争

哪个Sprintf导致了问题?什么是audioMapName?这一行:key:=fmt.Sprintf(“%s@%s@%s@%s@%s@%s@%d@%s”)…audioMapName是一个字符串对象。thx,我发现appId会被其他goroutineappId修改,PID是通过值传递的,这不是原因。