gosexy / redis

Redis client for Go that maps the full redis command list into equivalent Go functions.
MIT License
167 stars 44 forks source link

I got an error SIGSEGV: segmentation violation #29

Closed Icedroid closed 9 years ago

Icedroid commented 10 years ago

when run simultaneously It get an error and exit the program.

package models

import (
    "errors"
    "strconv"
    "log"

    "menteslibres.net/gosexy/redis"
)

var (
       client *r.Client
    host = "127.0.0.1"
    port = uint(6379)
)

func init(){
  client = redis.New()
  err := client.Connect(host, port)
  if err != nil {
     log.Fatalf("Connect failed: %s\n", err.Error())
  }
}
type Object struct {
    ObjectId   string 
    Score      int64
    PlayerName string
}

func RGetObject2() (object *Object, err error) {
    sl, err := client.HMGet(objectHashName, "ObjectId", "Score", "PlayerName")
    if nil != err {
        log.Printf("get object from redis hash get error %s", err)
        return
    }
    i, _ := strconv.ParseInt(sl[1], 10, 64)
    object = &Object{sl[0], i, sl[2]}
    //err = redis.ScanStruct(reply, object)
    return
}

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

runtime.cgocall(0x403980, 0x7f2f186812d8) /usr/local/go/src/pkg/runtime/cgocall.c:149 +0x11b fp=0x7f2f186812c0 menteslibres.net/gosexy/redis._Cfunc_redisCommandArgv(0x2c763e0, 0x5, 0xc210501630, 0xc210501660, 0xa) menteslibres.net/gosexy/redis/_obj/_cgo_defun.c:104 +0x31 fp=0x7f2f186812d8 menteslibres.net/gosexy/redis.(_Client).command(0xc21001ee10, 0x734a60, 0xc2105b5860, 0xc21060aa80, 0x5, ...) /home/ice/gopath/src/menteslibres.net/gosexy/redis/main.go:705 +0x364 fp=0x7f2f186813d8 menteslibres.net/gosexy/redis.(_Client).HMGet(0xc21001ee10, 0x8a2510, 0x6, 0x7f2f18681548, 0x3, ...) /home/ice/gopath/src/menteslibres.net/gosexy/redis/main.go:1530 +0x26d fp=0x7f2f18681480

xiam commented 10 years ago

Thanks for your report. Could you explain a bit more on how could I trigger the error?

xiam commented 9 years ago

This bug should be no longer valid, as we have removed the CGO dependency.