Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: SIGSEGV: segmentation violation .. net.cgoLookupIPCNAME #7857

Closed
gopherbot opened this issue Apr 24, 2014 · 3 comments
Closed

net: SIGSEGV: segmentation violation .. net.cgoLookupIPCNAME #7857

gopherbot opened this issue Apr 24, 2014 · 3 comments
Milestone

Comments

@gopherbot
Copy link

by stormgbs:

My go program crashed with errors:

SIGSEGV: segmentation violation
PC=0x3841478ce2
signal arrived during cgo execution

runtime.cgocall(0x4016c0, 0x7f60b4257748)
        /usr/local/go/src/pkg/runtime/cgocall.c:149 +0x11b fp=0x7f60b4257738
runtime.cmalloc(0x15)
        /usr/local/go/src/pkg/runtime/cgocall.c:200 +0x47 fp=0x7f60b4257760
net._Cfunc_CString(0xc211d68860, 0x14, 0x7f60fd34bf40)
        net/_obj/_cgo_defun.c:31 +0x2a fp=0x7f60b4257780
net.cgoLookupIPCNAME(0xc211d68860, 0x14, 0x0, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/net/cgo_unix.go:94 +0x124 fp=0x7f60b4257858
net.cgoLookupIP(0xc211d68860, 0x14, 0x0, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/net/cgo_unix.go:148 +0x69 fp=0x7f60b42578b0
net.lookupIP(0xc211d68860, 0x14, 0x0, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/net/lookup_unix.go:64 +0x63 fp=0x7f60b42578f8
net.func·022(0xc96680, 0xc210071000, 0xc211d68860, 0x14)
        /usr/local/go/src/pkg/net/lookup.go:41 +0x2d fp=0x7f60b4257948
net.(*singleflight).Do(0xc96680, 0xc211d68860, 0x14, 0x7f60b42579e0, 0x0, ...)
        /usr/local/go/src/pkg/net/singleflight.go:45 +0x1de fp=0x7f60b4257990
net.lookupIPMerge(0xc211d68860, 0x14, 0x0, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/net/lookup.go:42 +0xc0 fp=0x7f60b4257a40
net.lookupIPDeadline(0xc211d68860, 0x14, 0x0, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/net/lookup.go:57 +0xd0 fp=0x7f60b4257ac8
net.resolveInternetAddr(0x747960, 0x3, 0xc211d68860, 0x17, 0x0, ...)
        /usr/local/go/src/pkg/net/ipsock.go:285 +0x395 fp=0x7f60b4257b80
net.resolveAddr(0x73b9e0, 0x4, 0x747960, 0x3, 0xc211d68860, ...)
        /usr/local/go/src/pkg/net/dial.go:104 +0x32a fp=0x7f60b4257c18
net.(*Dialer).Dial(0x7f60b4257d78, 0x747960, 0x3, 0xc211d68860, 0x17, ...)
        /usr/local/go/src/pkg/net/dial.go:153 +0xa7 fp=0x7f60b4257d30
net.Dial(0x747960, 0x3, 0xc211d68860, 0x17, 0x5126be, ...)
        /usr/local/go/src/pkg/net/dial.go:138 +0x75 fp=0x7f60b4257db8
net/http.(*Transport).dial(0xc210059200, 0x747960, 0x3, 0xc211d68860, 0x17, ...)
        /usr/local/go/src/pkg/net/http/transport.go:401 +0xd4 fp=0x7f60b4257e00
net/http.(*Transport).dialConn(0xc210059200, 0xc212d82330, 0xc21339d380, 0x0, 0x0)
        /usr/local/go/src/pkg/net/http/transport.go:444 +0x6e fp=0x7f60b4257f50
net/http.func·014()
        /usr/local/go/src/pkg/net/http/transport.go:419 +0x3e fp=0x7f60b4257fa0
runtime.goexit()
        /usr/local/go/src/pkg/runtime/proc.c:1394 fp=0x7f60b4257fa8
created by net/http.(*Transport).getConn
        /usr/local/go/src/pkg/net/http/transport.go:421 +0x11a

In my program, I only used http.PostForm(), somebody said disable cgo may be worked.
but I have used cgo to replace bytes.Buffer.
So is there a good solution to avoid this crash?

some of my go code:
//Post start_time or end_time or Log
func PostCronData(apitype string, v *url.Values) (ret []byte, err error) {
        var api string
        switch apitype {
        case "log":
                api = fmt.Sprintf("http://%s%s", Config.domain, Config.postLogApi)
        case "time":
                api = fmt.Sprintf("http://%s%s", Config.domain, Config.updateTimeApi)
        default:
                return nil, errors.New(fmt.Sprintf("Can not find such api: %s", apitype))
        }
        // fmt.Println("Api:", api)
        DLogger.Debug("Api: %s", api)
        resp, err := http.PostForm(api, *v)
        if err != nil {
                return nil, err
        }
        defer resp.Body.Close()
        var buf []byte
        buf, err = ioutil.ReadAll(resp.Body)
        if err != nil {
                return nil, err
        }
        ret = buf
        return
}

thx u all !
@dvyukov
Copy link
Member

dvyukov commented Apr 24, 2014

Comment 1:

>but I have used cgo to replace bytes.Buffer.
How do you do it? Corrupted C heap would explain he crash.

@ianlancetaylor
Copy link
Contributor

Comment 2:

Which version of go are you using?
Can you show us your cgo code?

Labels changed: added repo-main, release-go1.3maybe.

@rsc
Copy link
Contributor

rsc commented May 9, 2014

Comment 3:

Status changed to TimedOut.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants