运行Blockchainr时出现恐慌:运行时错误:无效的内存地址或空指针解引用。

huangapple go评论91阅读模式
英文:

panic: runtime error: invalid memory address or nil pointer dereference when running Blockchainr

问题

我运行了blockchainr并获得了以下终端输出:

17:39:57 2015-06-16 [INF] 加载数据库leveldb
panic: 运行时错误:无效的内存地址或空指针解引用
	panic: 运行时错误:无效的内存地址或空指针解引用
[signal 0xb code=0x1 addr=0x0 pc=0x402cb63]

goroutine 1 [running]:
main.search(0x4911ef8, 0xc20806e2d0, 0x0, 0x0, 0x4911ef8)
	/Users/mesquka/Downloads/blockchainr-master/src/blockchainr/main.go:185 +0x3fa
main.main()
	/Users/mesquka/Downloads/blockchainr-master/src/blockchainr/main.go:284 +0x3ce

goroutine 5 [semacquire]:
sync.(*Cond).Wait(0xc208045100)
	/usr/local/go/src/sync/cond.go:62 +0x9e
github.com/conformal/seelog.(*asyncLoopLogger).processItem(0xc20802c4e0, 0x0)
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:50 +0xc2
github.com/conformal/seelog.(*asyncLoopLogger).processQueue(0xc20802c4e0)
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:63 +0x31
created by github.com/conformal/seelog.newAsyncLoopLogger
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:40 +0x8e

goroutine 6 [semacquire]:
sync.(*Cond).Wait(0xc2080452c0)
	/usr/local/go/src/sync/cond.go:62 +0x9e
github.com/conformal/seelog.(*asyncLoopLogger).processItem(0xc20802c5a0, 0x0)
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:50 +0xc2
github.com/conformal/seelog.(*asyncLoopLogger).processQueue(0xc20802c5a0)
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:63 +0x31
created by github.com/conformal/seelog.newAsyncLoopLogger
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:40 +0x8e

goroutine 7 [syscall]:
os/signal.loop()
	/usr/local/go/src/os/signal/signal_unix.go:21 +0x1f
created by os/signal.init·1
	/usr/local/go/src/os/signal/signal_unix.go:27 +0x35

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:2232 +0x1

goroutine 8 [chan receive]:
github.com/conformal/seelog.(*asyncAdaptiveLogger).processQueue(0xc208010150)
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_adaptivelogger.go:127 +0x89
created by github.com/conformal/seelog.newAsyncAdaptiveLogger
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_adaptivelogger.go:84 +0x6ba

我在OSX Yosemite 10.10.3上运行,使用的是go版本go1.4.2 darwin/amd64。

代码位于https://github.com/FiloSottile/blockchainr

我按照以下顺序运行了特定的命令:

  • make all
  • ./bin/btcd --datadir=~/Btcd/
  • ./bin/blockchainr -datadir ~/Btcd/

我在最后一个命令中获得了这个终端输出。

英文:

I run blockchainr and get the following terminal output:

17:39:57 2015-06-16 [INF] loading db leveldb
panic: runtime error: invalid memory address or nil pointer dereference
	panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x402cb63]

goroutine 1 [running]:
main.search(0x4911ef8, 0xc20806e2d0, 0x0, 0x0, 0x4911ef8)
	/Users/mesquka/Downloads/blockchainr-master/src/blockchainr/main.go:185 +0x3fa
main.main()
	/Users/mesquka/Downloads/blockchainr-master/src/blockchainr/main.go:284 +0x3ce

goroutine 5 [semacquire]:
sync.(*Cond).Wait(0xc208045100)
	/usr/local/go/src/sync/cond.go:62 +0x9e
github.com/conformal/seelog.(*asyncLoopLogger).processItem(0xc20802c4e0, 0x0)
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:50 +0xc2
github.com/conformal/seelog.(*asyncLoopLogger).processQueue(0xc20802c4e0)
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:63 +0x31
created by github.com/conformal/seelog.newAsyncLoopLogger
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:40 +0x8e

goroutine 6 [semacquire]:
sync.(*Cond).Wait(0xc2080452c0)
	/usr/local/go/src/sync/cond.go:62 +0x9e
github.com/conformal/seelog.(*asyncLoopLogger).processItem(0xc20802c5a0, 0x0)
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:50 +0xc2
github.com/conformal/seelog.(*asyncLoopLogger).processQueue(0xc20802c5a0)
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:63 +0x31
created by github.com/conformal/seelog.newAsyncLoopLogger
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_asynclooplogger.go:40 +0x8e

goroutine 7 [syscall]:
os/signal.loop()
	/usr/local/go/src/os/signal/signal_unix.go:21 +0x1f
created by os/signal.init·1
	/usr/local/go/src/os/signal/signal_unix.go:27 +0x35

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:2232 +0x1

goroutine 8 [chan receive]:
github.com/conformal/seelog.(*asyncAdaptiveLogger).processQueue(0xc208010150)
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_adaptivelogger.go:127 +0x89
created by github.com/conformal/seelog.newAsyncAdaptiveLogger
	/Users/mesquka/Downloads/blockchainr-master/src/github.com/conformal/seelog/behavior_adaptivelogger.go:84 +0x6ba

I am running on OSX Yosemite 10.10.3 with go version go1.4.2 darwin/amd64

The code is at https://github.com/FiloSottile/blockchainr

The specific commands I've run (in order) are:

  • make all
  • ./bin/btcd --datadir=~/Btcd/
  • ./bin/blockchainr -datadir ~/Btcd/

The last command is where I get this terminal output.

答案1

得分: 0

你的问题出在Blockchainr main.go的以下代码行:

var (
	dataDir = flag.String("datadir", filepath.Join(btcutil.AppDataDir("btcd", false), "data"), "BTCD: 数据目录")
	dbType  = flag.String("dbtype", "leveldb", "BTCD: 数据库后端")
)

如你所见,如果你没有指定dbtype标志,它默认为"leveldb",因此它期望datadir参数包含指向一个LevelDB数据库的路径。

英文:

Your problem lies with Blockchainr main.go following lines:

var (
	dataDir = flag.String("datadir", filepath.Join(btcutil.AppDataDir("btcd", false), "data"), "BTCD: Data directory")
	dbType  = flag.String("dbtype", "leveldb", "BTCD: Database backend")
)

As you can see, if you don't specify a dbtype flag it defaults to "leveldb" so it expects the datadir param to contains the path to a LevelDB database.

huangapple
  • 本文由 发表于 2015年6月16日 17:51:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/30864206.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定