douya1061 2014-12-04 23:49
浏览 87
已采纳

在没有已知原因的情况下进入“紧急:同步:解锁已解锁的互斥锁”

I have a cli application in Go (still in development) and no changes were made in source code neither on dependencies but all of a sudden it started to panic panic: sync: unlock of unlocked mutex.

The only place I'm running concurrent code is to handle when program is requested to close:

func handleProcTermination() {
    c := make(chan os.Signal, 1)
    signal.Notify(c, os.Interrupt)
    go func() {
        <-c
        curses.Endwin()
        os.Exit(0)
    }()
    defer curses.Endwin()
}

Only thing I did was to rename my $GOPATH and work space folder. Can this operation cause such error?

Have some you experienced any related problem without having any explanation? Is there a rational check list that would help to find the cause of the problem?

  • 写回答

2条回答 默认 最新

  • douxi3554 2014-12-05 00:47
    关注

    Ok, after some unfruitful debugging sessions, as a last resort, I simply wiped all third party code (dependencies) from the workspace:

    cd $GOPATH
    rm -rf pkg/ bin/ src/github.com  src/golang.org # the idea is to remove all except your own source
    

    Used go get to get all used dependencies again:

    go get github.com/yadayada/yada
    go get # etc
    

    And the problem is gone! Application is starting normally and tests are passing. No startup panics anymore. It looks like this problem happens when you mv your work space folder but I'm not 100% sure yet. Hope it helps someone else.

    From now on, re install dependencies will be my first step when weird panic conditions like that suddenly appear.

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

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?