Is it a bug? Golang OS. The strange Panic of Process in different environments
Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. # # # # # # # # # # # # # # # # The same code is different from CentOS 6.5 under MacOS 13.3 # # # # # # # # problem code ' go//This code is a MySQL Client, the incoming host, user, port and other parameters to do processing//here a co-monitoring singnal passed to the child process, to ensure that MySQL Clinet can monitor Singalgo func () {for {sig: = <-scswitch sig {case Syscall. sigint://MySQL clinet will be stdin monitoring SIGINT, re-incoming will cause two times kill//Proc. Signal (Syscall. SIGINT) Default:err: = Proc. Signal (SIG) if err! = Nil {Error.fatalln (ERR)}}}} () "The code was originally debug normal, and it took a while to get the package online." Recently wanted to add some new features to it, the results of the local compilation run when the panic. # # # Panic ' panic:runtime error:invalid memory address or nil pointer dereference[signal sigsegv:segmentation violatio n code=0x1 addr=0x0 Pc=0x40886ce]goroutine [Running]:os. (*process). Signal (0x0, 0x428a880, 0xc420132000, 0x0, 0x0)/ Usr/local/go/src/os/exec_unix.go:56 +0x2eos. (*process). Signal (0x0, 0x428a880, 0xc420132000, 0x0, 0x0)/usr/local/go/src/os/exec.go:129 +0x3fmain.main.func1 (0xc420072240, 0xc42000e058)/users/lepx/work/code/go/src/ku/ku.go:64 +0x80created by main.main/users/lepx/work/code/go/src/ku/ ku.go:56 +0x33d "' according to PAInc Information look down can see that this code out of the question "' Gofunc (P *process) signal (SIG signal) Error {if p.pid = =-1 {//here is/usr/local/go/src/os/exec_un Ix.go:56return errors. New ("Os:process already released")}if P.pid = = 0 {return errors. New ("Os:process not Initialized")}p.sigmu.rlock () defer p.sigmu.runlock () if P.done () {return errfinished}s, OK: = sig. ( Syscall. Signal) If!ok {return errors. New ("os:unsupported signal type")}if e: = Syscall. Kill (p.pid, s); E! = Nil {if E = = Syscall. Esrch {return errfinished}return E}return nil} ' "This code is normally compiled and run on CentOS. The first encounter Golang the same code in different environments compiled running state inconsistency problem, do not know if this is a bug. This problem is now found in 1.9.2 and 1.10. 464 reads
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.