From 82f5984de121716fa4c8c446f9edec5e17f79d76 Mon Sep 17 00:00:00 2001 From: "Star.LI" Date: Tue, 1 Sep 2020 17:22:53 +0800 Subject: [PATCH 1/2] fix crash - segment fault when partialFile.Allocated() is invoked. When openPartialFile is invoked, more errors than "existed error" are returned. If only existing error is checked, the allocated field of partialFile may be nil. Signed-off-by: Star.LI --- extern/sector-storage/ffiwrapper/sealer_cgo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/sector-storage/ffiwrapper/sealer_cgo.go b/extern/sector-storage/ffiwrapper/sealer_cgo.go index a72f5a66f37..c4e5511d1c2 100644 --- a/extern/sector-storage/ffiwrapper/sealer_cgo.go +++ b/extern/sector-storage/ffiwrapper/sealer_cgo.go @@ -371,7 +371,7 @@ func (sb *Sealer) ReadPiece(ctx context.Context, writer io.Writer, sector abi.Se maxPieceSize := abi.PaddedPieceSize(sb.ssize) pf, err := openPartialFile(maxPieceSize, path.Unsealed) - if xerrors.Is(err, os.ErrNotExist) { + if err != nil { return false, xerrors.Errorf("opening partial file: %w", err) } From ca7aa695978909c4a9715c00dce6658aac26a1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 2 Sep 2020 18:43:11 +0200 Subject: [PATCH 2/2] ffiwrapper: More correct error check on openPartialFile --- extern/sector-storage/ffiwrapper/sealer_cgo.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extern/sector-storage/ffiwrapper/sealer_cgo.go b/extern/sector-storage/ffiwrapper/sealer_cgo.go index c4e5511d1c2..d4f796dcb83 100644 --- a/extern/sector-storage/ffiwrapper/sealer_cgo.go +++ b/extern/sector-storage/ffiwrapper/sealer_cgo.go @@ -372,6 +372,10 @@ func (sb *Sealer) ReadPiece(ctx context.Context, writer io.Writer, sector abi.Se pf, err := openPartialFile(maxPieceSize, path.Unsealed) if err != nil { + if xerrors.Is(err, os.ErrNotExist) { + return false, nil + } + return false, xerrors.Errorf("opening partial file: %w", err) }