Initialize S3 with the SIGPIPE handler enabled. Without it, stale connections in the SDK's connection pool can trigger SIGPIPE during Aws::ShutdownAPI(), which causes R's signal handler to longjmp out of the teardown and segfault (GH-50009, GH-32026).
| 299 | // which causes R's signal handler to longjmp out of the teardown and segfault |
| 300 | // (GH-50009, GH-32026). |
| 301 | void EnsureS3InitializedWithSigpipeHandler() { |
| 302 | fs::S3GlobalOptions options = fs::S3GlobalOptions::Defaults(); |
| 303 | options.install_sigpipe_handler = true; |
| 304 | auto status = fs::InitializeS3(options); |
| 305 | // InitializeS3 returns Invalid if already initialized - that's fine |
| 306 | if (!status.ok() && !fs::IsS3Initialized()) { |
| 307 | StopIfNotOk(status); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | // [[s3::export]] |
| 312 | std::shared_ptr<fs::S3FileSystem> fs___S3FileSystem__create( |
no test coverage detected