Skip to content

Commit

Permalink
Fix calling Finalize on a dead instance
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Sep 16, 2024
1 parent 52386bf commit 380c531
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cpp/src/arrow/filesystem/s3fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3483,7 +3483,14 @@ Status EnsureS3Initialized() {
}

Status FinalizeS3() {
GetAwsInstance()->Finalize();
auto instance = GetAwsInstance();
// The AWS instance might already be destroyed in case FinalizeS3
// is called from an atexit handler (which is a bad idea anyway as the
// AWS SDK is not safe anymore to shutdown by this time). See GH-44071.
if (instance == nullptr) {
return Status::Invalid("FinalizeS3 called too late");
}
instance->Finalize();
return Status::OK();
}

Expand Down

0 comments on commit 380c531

Please sign in to comment.