Skip to content

Commit

Permalink
fix (prover): close file handles used in prover (#1007)
Browse files Browse the repository at this point in the history
Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
  • Loading branch information
silathdiir and 0xmountaintop authored Nov 7, 2023
1 parent 486c7ee commit 4aa5d5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions prover/core/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ func (p *ProverCore) mayDumpProof(id string, proofByt []byte) error {
if err != nil {
return err
}
defer func() {
if err = f.Close(); err != nil {
log.Error("failed to close proof dump file", "id", id, "error", err)
}
}()
log.Info("Saving proof", "task-id", id)
_, err = f.Write(proofByt)
return err
Expand Down
2 changes: 2 additions & 0 deletions prover/core/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func TestFFI(t *testing.T) {
func readChunkTrace(filePat string, as *assert.Assertions) []*types.BlockTrace {
f, err := os.Open(filePat)
as.NoError(err)
defer as.NoError(f.Close())
byt, err := io.ReadAll(f)
as.NoError(err)

Expand All @@ -104,6 +105,7 @@ func readChunkTrace(filePat string, as *assert.Assertions) []*types.BlockTrace {
func readVk(filePat string, as *assert.Assertions) string {
f, err := os.Open(filePat)
as.NoError(err)
defer as.NoError(f.Close())
byt, err := io.ReadAll(f)
as.NoError(err)

Expand Down

0 comments on commit 4aa5d5c

Please sign in to comment.