ncw / swift

Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)
MIT License
313 stars 107 forks source link

Random Segmentation fault - Uploading file #76

Closed renatocron closed 8 years ago

renatocron commented 8 years ago

Hello,

I'm new very to go and I just installed it on ubuntu 14.04 using apt-get. Here is my go version go version xgcc (Ubuntu 4.9.3-0ubuntu4) 4.9.3 linux/amd64

my test script:

package main

import (
    "fmt"
    "bytes"
    "github.com/ncw/swift"
)

func main() {
    // Create a v1 auth connection
    c := &swift.Connection{
        // This should be your username
        UserName: "username",
        // This should be your api key
        ApiKey: "foobar",
        // This should be a v1 auth url, eg
        //  Rackspace US        https://auth.api.rackspacecloud.com/v1.0
        //  Rackspace UK        https://lon.auth.api.rackspacecloud.com/v1.0
        //  Memset Memstore UK  https://auth.storage.memset.com/v1.0
        AuthUrl: "https://sao01.objectstorage.softlayer.net/auth/v1.0/",
    }

    // Authenticate
    err := c.Authenticate()
    if err != nil {
        panic(err)
    }

    /*
    // List all the containers
    containers, err := c.ContainerNames(nil)
    fmt.Println(containers)
    // etc...
*/

    // c.ObjectPut("bnovo-201608", "testgox", "XABC", "")
    headers := swift.Headers{}
    // Now set content size correctly
    contents := bytes.NewBufferString("ABCDE")
    //headers["Content-Length"] = strconv.FormatInt(CONTENT_SIZE, 10)
    h, err := c.ObjectPut("saopaulo", "testgo", contents, false, "", "text/plain", headers)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(h)

    // as above...
}

When I run this, sometimes it work, sometimes not:

renato@renato-Inspiron-5420:~/projetos/go/src/github.com/renatocron/hello-world-swift$ go run hello.go 
map[X-Trans-Id:tx4c759a66c5924032b88fb-0057c2a657 Date:Sun, 28 Aug 2016 08:52:39 GMT Last-Modified:Sun, 28 Aug 2016 08:52:40 GMT Content-Type:text/html; charset=UTF-8 Content-Length:0 Etag:2ecdde3959051d913f61b14579ea136d]
renato@renato-Inspiron-5420:~/projetos/go/src/github.com/renatocron/hello-world-swift$ go run hello.go 
signal: Segmentation fault (core dumped)
renato@renato-Inspiron-5420:~/projetos/go/src/github.com/renatocron/hello-world-swift$ go run hello.go 
signal: Segmentation fault (core dumped)
renato@renato-Inspiron-5420:~/projetos/go/src/github.com/renatocron/hello-world-swift$ go run hello.go 
signal: Segmentation fault (core dumped)
renato@renato-Inspiron-5420:~/projetos/go/src/github.com/renatocron/hello-world-swift$ go run hello.go 
signal: Segmentation fault (core dumped)
renato@renato-Inspiron-5420:~/projetos/go/src/github.com/renatocron/hello-world-swift$ go run hello.go 
^[[Amap[X-Trans-Id:tx6725b0e88b854f1488f73-0057c2a65b Date:Sun, 28 Aug 2016 08:52:43 GMT Last-Modified:Sun, 28 Aug 2016 08:52:44 GMT Content-Type:text/html; charset=UTF-8 Content-Length:0 Etag:2ecdde3959051d913f61b14579ea136d]
renato@renato-Inspiron-5420:~/projetos/go/src/github.com/renatocron/hello-world-swift$ go run hello.go 
signal: Segmentation fault (core dumped)
renato@renato-Inspiron-5420:~/projetos/go/src/github.com/renatocron/hello-world-swift$ go run hello.go 
signal: Segmentation fault (core dumped)
renato@renato-Inspiron-5420:~/projetos/go/src/github.com/renatocron/hello-world-swift$ go run hello.go 
signal: Segmentation fault (core dumped)

I'm using sao01.objectstorage.softlayer.net and I'm running mtr to see if I have any package loss, but that do not seem to happen too often (none in a few minutes)

renatocron commented 8 years ago

It looks something related with HTTPS.

I used an nc -l 3000 and use AuthUrl: "http://localhost:3000/auth/v1.0/" and responded with valid HTTP urls instead of https and it worked all times (except when I did something wrong such pasting invalid http response on nc)

I will try to use another openstack provider

ymmt2005 commented 8 years ago

You are using gccgo which is not used widely. Install golang from apt, or download the latest go from https://golang.org/dl/ .

renatocron commented 8 years ago

@ymmt2005 Thanks for saying that! Now I get error messages!

I setup one account on memset (waiting for rackspace verification) and now I have:

$ go run hello.go

panic: Get https://auth.storage.memset.com/v1.0: x509: certificate signed by unknown authority (possibly because of "x509: cannot verify signature: algorithm unimplemented" while trying to verify candidate authority certificate "COMODO RSA Certification Authority")

goroutine 1 [running]:
runtime.panic(0x620320, 0xc21024d030)
    /usr/lib/go/src/pkg/runtime/panic.c:266 +0xb6
main.main()
    /home/renato/projetos/go/src/github.com/renatocron/hello-world-swift/hello.go:27 +0xd6

goroutine 6 [syscall]:
runtime.goexit()
    /usr/lib/go/src/pkg/runtime/proc.c:1394
exit status 2

I added "crypto/tls" and TLSClientConfig: &tls.Config{InsecureSkipVerify: true} and it worked fine with memset too.

And they don't have port 80 open, so I can't test if it would work fine there.

--- BUT! There's good news, using golang I could run about ~ 30 executions without any failure (both using dal05.objectstorage.softlayer.net [230ms, few package loss] and sao01.objectstorage.softlayer.net [11ms, no package loss]) so I think gccgo was the issue.

Edit 2: I don't know root the cause, should I open a ticket on gccgo repository?

ncw commented 8 years ago

Check the FAQ for a solution to the certificate error.

I suspect you are using an embedded distribution or something like that. (Can't load the github page over gprs!)