dreamwind1985 2016-08-05 22:00
浏览 499
已采纳

如何在golang中捕获堆栈溢出错误

Is there any way to catch stack overflow error in golang? Currently I'm using go recover() do this job(below code snippet), looks like stack overflow error can't be caught.

defer func() {
            if x := recover(); x != nil {
                log.Error("In recover, cought error====================", x)
            }
        }()

fn(xxx)
  • 写回答

3条回答 默认 最新

  • dshmvqnl98119 2016-08-05 22:16
    关注

    What you see in the output is a "fatal error", not a panic.

    fatal error: stack overflow
    

    You can only use recover() to recover from panics. A stack overflow is a fatal error thrown by the runtime which causes the process to print a stack trace and exit.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿