Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

A Bug found when execute " hset " command. #22

Open
openinx opened this issue Jun 26, 2014 · 1 comment
Open

A Bug found when execute " hset " command. #22

openinx opened this issue Jun 26, 2014 · 1 comment

Comments

@openinx
Copy link

openinx commented Jun 26, 2014

127.0.0.1:6389> hset test  good boy 
Could not connect to Redis at 127.0.0.1:6389: Connection refused

there some traceback logs from server-side:

panic: runtime error: assignment to entry in nil map

goroutine 20 [running]:
runtime.panic(0x544d00, 0x631cf3)
        /usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
redis.(*DefaultHandler).Hset(0xc208040140, 0xc2080004c8, 0x7, 0xc208000540, 0x4, 0xc208063200, 0x3, 0x600, 0x0, 0x0, ...)
        /home/openinx/software/go-redis-server-master/src/redis/defaultHandler.go:245 +0x6c3
reflect.Value.call(0x536240, 0x551d78, 0x0, 0x130, 0x55def0, 0x4, 0xc208046080, 0x4, 0x4, 0x0, ...)
        /usr/local/go/src/pkg/reflect/value.go:563 +0x1210
reflect.Value.Call(0x536240, 0x551d78, 0x0, 0x130, 0xc208046080, 0x4, 0x4, 0x0, 0x0, 0x0)
        /usr/local/go/src/pkg/reflect/value.go:411 +0xd7
redis.func·001(0xc208018280, 0x0, 0x0, 0x0, 0x0)
        /home/openinx/software/go-redis-server-master/src/redis/auto.go:94 +0xdbd
redis.(*Server).Apply(0xc20804a140, 0xc208018280, 0x0, 0x0, 0x0, 0x0)
        /home/openinx/software/go-redis-server-master/src/redis/handler.go:39 +0x13d
redis.(*Server).ServeClient(0xc20804a140, 0x7fcf810fd518, 0xc20803a1b8, 0x0, 0x0)
        /home/openinx/software/go-redis-server-master/src/redis/server.go:98 +0x323
created by redis.(*Server).Serve
        /home/openinx/software/go-redis-server-master/src/redis/server.go:50 +0x12f

goroutine 16 [IO wait]:
net.runtime_pollWait(0x7fcf810fd468, 0x72, 0x0)
        /usr/local/go/src/pkg/runtime/netpoll.goc:146 +0x66
net.(*pollDesc).Wait(0xc20802a140, 0x72, 0x0, 0x0)
        /usr/local/go/src/pkg/net/fd_poll_runtime.go:84 +0x46
net.(*pollDesc).WaitRead(0xc20802a140, 0x0, 0x0)
        /usr/local/go/src/pkg/net/fd_poll_runtime.go:89 +0x42
net.(*netFD).accept(0xc20802a0e0, 0x5a5908, 0x0, 0x7fcf810fc2b8, 0xb)
        /usr/local/go/src/pkg/net/fd_unix.go:409 +0x343
net.(*TCPListener).AcceptTCP(0xc20803a1b0, 0x28, 0x0, 0x0)
        /usr/local/go/src/pkg/net/tcpsock_posix.go:234 +0x5d
net.(*TCPListener).Accept(0xc20803a1b0, 0x0, 0x0, 0x0, 0x0)
        /usr/local/go/src/pkg/net/tcpsock_posix.go:244 +0x4b
redis.(*Server).Serve(0xc20804a140, 0x7fcf810fc498, 0xc20803a1b0, 0x0, 0x0)
        /home/openinx/software/go-redis-server-master/src/redis/server.go:46 +0xc6
redis.(*Server).ListenAndServe(0xc20804a140, 0x0, 0x0)
        /home/openinx/software/go-redis-server-master/src/redis/server.go:36 +0x190
main.main()
        /home/openinx/software/go-redis-server-master/src/main/main.go:12 +0x7b

goroutine 19 [finalizer wait]:
runtime.park(0x412eb0, 0x635818, 0x634389)
        /usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x635818, 0x634389)
        /usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
        /usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
        /usr/local/go/src/pkg/runtime/proc.c:1445

goroutine 21 [runnable]:
redis.func·013()
        /home/openinx/software/go-redis-server-master/src/redis/server.go:68
created by redis.(*Server).ServeClient
        /home/openinx/software/go-redis-server-master/src/redis/server.go:76 +0x140

After review the code, I found a bug from file defaultHandler.go.



func NewDatabase(parent *Database) *Database {
    db := &Database{
        values:   make(HashValue),
        sub:      make(HashSub),
        brstack:  make(HashBrStack),
        children: map[int]*Database{},
        parent:   parent,
    }
    db.children[0] = db
    return db
}

I think you just forget make a map for hvalues :

func NewDatabase(parent *Database) *Database {
    db := &Database{
        values:   make(HashValue),
        hvalues:  make(HashHash),
        sub:      make(HashSub),
        brstack:  make(HashBrStack),
        children: map[int]*Database{},
        parent:   parent,
    }
    db.children[0] = db
    return db
}
@ykumar-rb
Copy link

Even I have faced similar issue. Thanks @openinx , the fix works perfectly ok. Can you check if you can contribute to this project. This fix should go to master branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants