filecoin-project / lotus

Reference implementation of the Filecoin protocol, written in Go
https://lotus.filecoin.io/
Other
2.85k stars 1.27k forks source link

Crash when executing <lotus paych get> in testnet/3 [bug] #1611

Closed diwufeiwen closed 4 years ago

diwufeiwen commented 4 years ago

Describe the bug: Crash when executing command [./lotus paych get t3 t3 value] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xf46d1b]

goroutine 5899 [running]: github.com/filecoin-project/lotus/paychmgr.(Manager).waitForPaychCreateMsg(0xc00606c790, 0x27fce40, 0xc000335410, 0xc007200c00, 0x26) /home/data/jenkins/workspace/lotus-force-build/paychmgr/simple.go:63 +0x15b created by github.com/filecoin-project/lotus/paychmgr.(Manager).createPaych /home/data/jenkins/workspace/lotus-force-build/paychmgr/simple.go:48 +0x3b7

Fix: waitForPaychCreateMsg func has null pointer in paychmgr/simple.go mwait, err := pm.state.StateWaitMsg(ctx, mcid) if err != nil { log.Errorf("wait msg: %w", err) }

if err is not nil,mwait may be a null pointer

if mwait.Receipt.ExitCode != 0 { log.Errorf("payment channel creation failed (exit code %d)", mwait.Receipt.ExitCode) } Branch: testnet/3

Supplement Info: 2020-04-26T09:58:26.575+0800 ERROR paych paychmgr/simple.go:60 wait msg: %!w(*errors.errorString=&{context canceled})

go pm.waitForPaychCreateMsg(ctx mcid) in createPaych func go pm.waitForAddFundsMsg(ctx, mcid) in addFunds func ctx from ctx, span := trace.StartSpan(context.Background(), "/cli") in cmd main func,so ctx has been released in main thread.

ctx := ReqContext(cctx) func ReqContext(cctx *cli.Context) context.Context { tCtx := DaemonContext(cctx)

ctx, done := context.WithCancel(tCtx) sigChan := make(chan os.Signal, 2) go func() { <-sigChan done() }() signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP)

return ctx }

asutula commented 4 years ago

Just bumped into this as well in our work on Powergate, glad to see I'm not the only one :)

whyrusleeping commented 4 years ago

This happens because we don't return after logging an error here: https://github.com/filecoin-project/lotus/blob/master/paychmgr/simple.go#L60

We could just add a return, but I think this needs a little bit more thought than that.