Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-7470] Fix peer chaincode upgrade SIGSEGV panic
Before this change ugrading the chaincode following the Reconfigure your network tutorial fails with a panic: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xbb36bb] goroutine 1 [running]: github.com/hyperledger/fabric/peer/chaincode.chaincodeUpgrade(0x0, 0xc420 3c4720, 0x0, 0x0) /opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/upgr ade.go:141 +0x4b [...] main.main() /opt/gopath/src/github.com/hyperledger/fabric/peer/main.go:112 +0 x493 After this change, the command succeeds as expected. This CR adds a related test to cover the issue. $ go test -v -run TestUpgradeCmdWithNilCF github.com/hyperledger/fabric/p eer/chaincode === RUN TestUpgradeCmdWithNilCF --- FAIL: TestUpgradeCmdWithNilCF (0.02s) Error Trace: upgrade_test.go:86 asm_amd64.s:509 panic.go:491 panic.go:63 signal_unix.go:367 upgrade.go:135 upgrade.go:43 command.go:599 command.go:689 command.go:648 upgrade_test.go:98 Error: Received unexpected error "runtime error: invalid memory address or nil pointer dereference" Messages: 'peer chaincode upgrade' command should have fail ed without a panic FAIL exit status 1 FAIL github.com/hyperledger/fabric/peer/chaincode 0.042s $ go test -v -run TestUpgradeCmdWithNilCF github.com/hyperledger/fabric/p eer/chaincode === RUN TestUpgradeCmdWithNilCF Error: Error getting endorser client chaincode: error trying to connect t o local peer: context deadline exceeded Usage: upgrade [flags] [...] --- PASS: TestUpgradeCmdWithNilCF (3.03s) PASS ok github.com/hyperledger/fabric/peer/chaincode 3.045s Before CR: $ go test -cover github.com/hyperledger/fabric/peer/chaincode ok github.com/hyperledger/fabric/peer/chaincode 0.559s coverage: 81.3% of statements After CR: $ go test -cover github.com/hyperledger/fabric/peer/chaincode ok github.com/hyperledger/fabric/peer/chaincode 3.611s coverage: 81.8% of statements Change-Id: I65a7846c77481ff7dcddb410aebe74b8d6eb005c Signed-off-by: Arnaud J Le Hors <[email protected]>
- Loading branch information