doucai6663 2016-03-09 19:38
浏览 626

如何分析Go(golang)崩溃日志

So my application crashed and I can't for the life of me figure out what the problem is only from the error messages. Because it ran for hours fine.

this is the error

(err): net.(*pollDesc).WaitRead(0xc20802ac30, 0x0, 0x0)
(err):     /usr/lib/go/src/pkg/net/fd_poll_runtime.go:89 +0x42
(err): net.(*netFD).Read(0xc20802abd0, 0xc208083000, 0x1000, 0x1000, 0x0, 0x7fab4f8082b8, 0xb)
(err):     /usr/lib/go/src/pkg/net/fd_unix.go:242 +0x34c
(err): net.(*conn).Read(0xc208038090, 0xc208083000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
(err):     /usr/lib/go/src/pkg/net/net.go:122 +0xe7
(err): bufio.(*Reader).fill(0xc208004540)
(err):     /usr/lib/go/src/pkg/bufio/bufio.go:97 +0x1b3
(err): bufio.(*Reader).ReadSlice(0xc208004540, 0x7ffff8000000000a, 0x0, 0x0, 0x0, 0x0, 0x0)
(err):     /usr/lib/go/src/pkg/bufio/bufio.go:298 +0x22c
(err): bufio.(*Reader).ReadLine(0xc208004540, 0x0, 0x0, 0x0, 0x200, 0x0, 0x0)
(err):     /usr/lib/go/src/pkg/bufio/bufio.go:326 +0x69
(err): net/textproto.(*Reader).readLineSlice(0xc208022d50, 0x0, 0x0, 0x0, 0x0, 0x0)
(err):     /usr/lib/go/src/pkg/net/textproto/reader.go:55 +0x9d
(err): net/textproto.(*Reader).ReadLine(0xc208022d50, 0x0, 0x0, 0x0, 0x0)
(err):     /usr/lib/go/src/pkg/net/textproto/reader.go:36 +0x4e
(err): main.(*Bot).ListenToConnection(0xc208046460, 0x7fab4f809518, 0xc208038090)
(err):     /home/gempir/gempbroker/main.go:73 +0xab
(err): created by main.(*Bot).CreateConnection
(err):     /home/gempir/gempbroker/main.go:106 +0x8a3

I found that main.go:73 which is a simple Readline reading from a TCP connection

reader := bufio.NewReader(conn)
    tp := textproto.NewReader(reader)
    for {
        line, err := tp.ReadLine()
        if err != nil {
            break // break loop on errors
        }
        // do stuff
    }

main.go:106 just creates a goroutine for listening to the connection

go listenToConnection(conn)

How do I find out what the error logs actually mean and find a solution to my problem?

  • 写回答

1条回答 默认 最新

  • dsiimyoc804955 2016-03-09 20:30
    关注

    If you follow the stack trace, you can see that, as expected, you are polling a network (TCP connection). Networks are fragile; you must expect errors and handle them gracefully.

    reader := bufio.NewReader(conn)
    tp := textproto.NewReader(reader)
    for {
        line, err := tp.ReadLine()
        if err != nil {
            break // break loop on errors
        }
        // do stuff
    }
    

    If an error occurs here

    line, err := tp.ReadLine()
    

    you discard it

        if err != nil {
            break // break loop on errors
        }
    

    and keep going, pretending nothing happened

    for {
        line, err := tp.ReadLine()
        if err != nil {
            break // break loop on errors
        }
        // do stuff
    }
    

    On the next

    line, err := tp.ReadLine()
    

    after an error, the results are undefined.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100