dqroktbn005028 2019-03-01 05:45
浏览 102

Golang中的Sprintf访问段冲突

I encontered the segmentation violation error when I use Sprintf in my golang code. Anyboy know what's wrong with my code? My code as following:


func createTrainingPath(trainingPrefix string, uuid string, codec string) string {
    return fmt.Sprintf("%s/%s/%s/%s", trainingPrefix, codec, time.Now().Format("20060102"), uuid)
}

The error as following:

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

goroutine 7483565 [running]:
panic(0x1162ea0, 0x19558e0)
        /home/wenchuang.liu/go/src/runtime/panic.go:540 +0x45e fp=0xc494a569f0 sp=0xc494a56948 pc=0x697f4e
runtime.panicmem()
        /home/wenchuang.liu/go/src/runtime/panic.go:63 +0x5e fp=0xc494a56a10 sp=0xc494a569f0 pc=0x696c7e
runtime.sigpanic()
        /home/wenchuang.liu/go/src/runtime/signal_unix.go:367 +0x17c fp=0xc494a56a60 sp=0xc494a56a10 pc=0x6af2dc
runtime.memmove(0xc4200e2419, 0x0, 0x20)
        /home/wenchuang.liu/go/src/runtime/memmove_amd64.s:178 +0x147 fp=0xc494a56a68 sp=0xc494a56a60 pc=0x6ca1f7
fmt.(*buffer).WriteString(...)
        /home/wenchuang.liu/go/src/fmt/print.go:82
fmt.(*fmt).padString(0xc47dafe040, 0x0, 0x20)
        /home/wenchuang.liu/go/src/fmt/format.go:110 +0x9c fp=0xc494a56af0 sp=0xc494a56a68 pc=0x7365fc
fmt.(*fmt).fmt_s(0xc47dafe040, 0x0, 0x20)
        /home/wenchuang.liu/go/src/fmt/format.go:328 +0x61 fp=0xc494a56b28 sp=0xc494a56af0 pc=0x7373a1
fmt.(*pp).fmtString(0xc47dafe000, 0x0, 0x20, 0x7f3300000073)
        /home/wenchuang.liu/go/src/fmt/print.go:433 +0x197 fp=0xc494a56b60 sp=0xc494a56b28 pc=0x73b077
fmt.(*pp).printArg(0xc47dafe000, 0x1131bc0, 0xc4c6f94200, 0x73)
        /home/wenchuang.liu/go/src/fmt/print.go:664 +0x7b5 fp=0xc494a56be0 sp=0xc494a56b60 pc=0x73d355
fmt.(*pp).doPrintf(0xc47dafe000, 0x1232d53, 0xb, 0xc494a56dd0, 0x4, 0x4)
        /home/wenchuang.liu/go/src/fmt/print.go:996 +0x15a fp=0xc494a56d10 sp=0xc494a56be0 pc=0x740cea
fmt.Sprintf(0x1232d53, 0xb, 0xc494a56dd0, 0x4, 0x4, 0xc4c48478d8, 0x8)
        /home/wenchuang.liu/go/src/fmt/print.go:196 +0x66 fp=0xc494a56d68 sp=0xc494a56d10 pc=0x739226
i7zuoye.com/ago/gomark/service/utils.createTrainingPath(0x0, 0x20, 0x122f9f1, 0x6, 0xc42c2c9560, 0xc4209e0f68)
        /home/wenchuang.liu/gohere/src/i7zuoye.com/ago/gomark/service/utils/media.go:210 +0x190 fp=0xc494a56e20 sp=0xc494a56d68 pc=0xbdc6f0
i7zuoye.com/ago/gomark/service/utils.SaveResult(0x0, 0x20, 0xc4909e4a00, 0xf5e, 0x134f, 0x865823, 0xc4206b0301, 0xc4209e0fa8, 0x865823)
        /home/wenchuang.liu/gohere/src/i7zuoye.com/ago/gomark/service/utils/media.go:116 +0x51 fp=0xc494a56e98 sp=0xc494a56e20 pc=0xbdaf41
i7zuoye.com/ago/gomark/service/evaluate/stream.sendResponse.func1(0xc4acdfbe60, 0xc4909e4a00, 0xf5e, 0x134f, 0xc4371bc410, 0xc8, 0x0, 0x0, 0x0, 0x12392fd, ...)
        /home/wenchuang.liu/gohere/src/i7zuoye.com/ago/gomark/service/evaluate/stream/streamserver.go:390 +0x73 fp=0xc494a56f40 sp=0xc494a56e98 pc=0xbf3593
runtime.goexit()
        /home/wenchuang.liu/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc494a56f48 sp=0xc494a56f40 pc=0x6c9901
created by i7zuoye.com/ago/gomark/service/evaluate/stream.sendResponse
        /home/wenchuang.liu/gohere/src/i7zuoye.com/ago/gomark/service/evaluate/stream/streamserver.go:389 +0x179

Any help would be appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮