• 日常工作:一个死锁问题的查验


    问题说明:程序出现问题,上层业务检查后说,一个命令下去后,没有收到返回值,应该是阻塞导致的。查看了相关接口,发现该出有一个加锁的操作,可能是因为死锁导致的。

    问题查验:使用pstack+pid的方式,查看是否程序卡某处了。然后发现经常在同一个位置。

    Thread 154 (Thread 0x131c7b40 (LWP 23358)):
    #0  0xf5fc693e in g_malloc () from /lib/libglib-2.0.so.0
    #1  0xf7285c03 in CCodecWrapBuffer::CCodecWrapBuffer(long) () from /opt/mcu/mpu/lib/libcodecwrapper_x86.so
    #2  0xf7289b44 in CImageMergeWrapper::SetBufList(_GList*, int) () from /opt/mcu/mpu/lib/libcodecwrapper_x86.so
    #3  0xf7299a18 in MergeProcess(void*) () from /opt/mcu/mpu/lib/libcodecwrapper_x86.so
    #4  0xf5fe7f7a in g_thread_proxy () from /lib/libglib-2.0.so.0
    #5  0xf5f9101d in g_deprecated_thread_proxy () from /lib/libglib-2.0.so.0
    #6  0xf5f57b2c in start_thread () from /lib/libpthread.so.0
    #7  0xf5d2a77e in clone () from /lib/libc.so.6

    然后再查看此处(pstrace 23358),一直卡在里边,是在线程中使用了同一把锁,一直malloc失败导致一直占用着锁,导致其他线程拿不到锁,所以会产生上述阻塞的问题。

    那么为什么会malloc失败呢?

    top -p看一下,原来虚拟内存不足了(32位程序,4G内存,此时已经占用了3.7G)。

    是不是内存泄漏了 ?那问题可就大了,查看一下程序运行的时间。

    ps -p PID -o lstart,etime
    

     卧槽,已经运行了140多天,那内存泄漏也不好查了。

    目前的经验只能先杀了程序,重启一下。以后的策略,应该应对一下,如果程序一直跑着,则定期重启(如果占用CPU很低的情况下)。

    参考网站:

    https://www.cnblogs.com/shenlinken/p/8157204.html    排查程序死循环,死锁的方法

    http://blog.51cto.com/leomars/1888213        PS命令查看进程启动时间和运行时间

  • 相关阅读:
    SpringBoot整合ActiveMQ同时支持P2P和发布订阅模式(三)
    SpringBoot整合ActiveMQ的publish/subscribe发布订阅模式(二)
    Windows启动ActiveMQ报Wrapper Stopped错误
    IDEA从远程仓库克隆项目
    Git的安装
    IDEA上传项目到使用github上
    Mybaits的逆向工程
    posman测试接口需要登录验证的使用
    SSM整合SpringSecurity
    SpringBoot整合MongoDB的连接用户名和密码问题
  • 原文地址:https://www.cnblogs.com/whutao/p/10405113.html
Copyright © 2020-2023  润新知