27

Golang-进程无故消失?

 5 years ago
source link: https://studygolang.com/articles/15179?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

导致进程消失原因:64位操作系统中,写一个溢出指针到内存的非指针字符(a non-pointer word of memory),导致GC的时,不能看到该溢出块,所以导致GC过早回收该块,然后就导致崩溃(目前在NaCl/amd64p32已发现该问题)。

Let‘s Go!

1.解决方案

本文提供3钟方案可选:

  • 升级Golang编译版本 1.5->1.8 (必须)
  • 增加进程监控
  • 增加supervior管理进程

2.环境

  • Golang version:1.5
  • Linux version:Linux version 2.6.32-279.el6.x86_64 (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) )
  • Os version:CentOS release 6.3 (Final) 2.6.32-279.el6.x86_64
  • Cpu :12
  • Mem :8G

3.问题现象

错误信息

fatal error: bad map state

goroutine 89 [running]:
runtime.throw(0x990ca0, 0xd)
        /usr/local/go/src/runtime/panic.go:527 +0x90 fp=0xc8323e9bb0 sp=0xc8323e9b98
runtime.evacuate(0x803440, 0xc8200f4c30, 0x6b)
        /usr/local/go/src/runtime/hashmap.go:825 +0x3b1 fp=0xc8323e9c70 sp=0xc8323e9bb0
runtime.growWork(0x803440, 0xc8200f4c30, 0xa5)
        /usr/local/go/src/runtime/hashmap.go:795 +0x83 fp=0xc8323e9c90 sp=0xc8323e9c70
runtime.mapassign1(0x803440, 0xc8200f4c30, 0xc8323e9d60, 0xc8323e9d70)
        /usr/local/go/src/runtime/hashmap.go:433 +0x176 fp=0xc8323e9d38 sp=0xc8323e9c90
............

4.问题原因

  • 64位操作系统中,写一个溢出指针到内存的非指针字符(a non-pointer word of memory),导致GC的时,不能看到该溢出块,所以导致GC过早回收该块,然后就导致崩溃(目前在NaCl/amd64p32已发现该问题)。

使用go版本1.5与目前线上版本一致,推断因该问题引起。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK