【问题标题】:panic: runtime error: invalid memory address or nil pointer dereference when running Blockchainr恐慌:运行时错误:运行 Blockchainr 时内存地址无效或无指针取消引用
【发布时间】:2015-06-16 09:51:37
【问题描述】:

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

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

我在 OSX Yosemite 10.10.3 上运行 go1.4.2 darwin/amd64

代码在https://github.com/FiloSottile/blockchainr

我运行的具体命令(按顺序)是:

  • 全力以赴
  • ./bin/btcd --datadir=~/Btcd/
  • ./bin/blockchainr -datadir ~/Btcd/

最后一个命令是我得到这个终端输出的地方。

【问题讨论】:

  • 你的问题是什么?
  • blockchainr 是您的代码吗?如果您查看堆栈跟踪,db 为零。您需要确保不会发生这种情况。

标签: go blockchain


【解决方案1】:

您的问题在于Blockchainr main.go 以下几行:

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

如您所见,如果您未指定 dbtype 标志,则默认为 "leveldb",因此它期望 datadir 参数包含 LevelDB 数据库的路径。

【讨论】:

  • 谢谢!知道应该将数据库设置为什么吗?
  • 不幸的是,它非常依赖于应用程序,您可以在这里查看github.com/FiloSottile/blockchainr/blob/master/src/github.com/… 了解如何添加数据库驱动程序
  • 修复:新的 btcd 忽略指定的 --data-dir 参数和存储在库中的数据(在 OSX 中,不确定其他操作系统)
  • 我注意到blockchainr的“vendor”src没有更新(甚至文件夹结构改变了,文档链接也被破坏了)。嗯,这样更好! :)
  • 我对 Go 很陌生,我只是用区块链作为一种同时学习 Go 和 ECDSA 的方式
猜你喜欢
  • 2013-04-23
  • 2015-02-24
  • 2022-01-05
  • 1970-01-01
  • 2023-01-11
  • 2019-09-12
  • 1970-01-01
  • 2016-12-12
  • 1970-01-01
相关资源
最近更新 更多