Repository navigation
Conversation
The ROS3 VFD's event loop group and host resolver were only released in an atexit() handler. Their threads are "managed" aws-c-common threads, so another aws-c-* user in the same process deadlocks if it shuts down before exit(). For example, Aws::ShutdownAPI() in the AWS C++ SDK, as called by OPeNDAP BES when unloading modules, waits forever for the ROS3 threads because it joins all managed threads. On non-Windows platforms, H5FD__s3comms_term() (H5close()) now releases the event loop group and host resolver, so their threads exit. aws_s3_library_clean_up() also joins every managed thread in the process, including threads owned by other aws-c-* users, so it stays in the atexit() handler. The library init and atexit() registration happen only once, so the interface can be re-initialized after H5close(). Windows keeps its existing behavior: no atexit() handler is registered and H5close() performs the full cleanup. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Review ChecklistThis PR touches the following areas. Each needs a sign-off
|
jhendersonHDF
left a comment
There was a problem hiding this comment.
The VFD should not be left in a half-initialized state like this between close and re-initialization of HDF5, as we cannot predict what changes to aws-c-s3 this will have on the eventual full cleanup process. All cleanup should be performed all at once, ideally during H5close() but since calling that isn't a requirement currently it has to be done during an atexit() handler. This is exactly why the Windows deadlock had to be worked around in an awkward fashion and other VFDs have similar problems. I consider this an inherent limitation of HDF5 currently and it should just be noted not to use the ROS3 VFD in this way until we can make H5close() an application requirement.
|
Thanks for the review, @jhendersonHDF. I understand the preference for a single cleanup point, but I think the risk is somewhat overstated for this change:
That said, I agree there are edge cases worth handling, e.g. another aws-c-* user calling
I'm happy to rework the PR in whichever direction you think is best. |
|
Correction to my previous comment: after checking the source, aws-c-s3's tests and aws-crt-cpp's |
I expect the normal lifecycle for aws-c-s3 applications is different than HDF5 applications. When
Sure, also no problem here in general, other than that
Sure, no problem here.
Yes, this is a known (currently undocumented) limitation because HDF5 doesn't require calling
I could see this being done as a workaround for the time being; I would prefer an environment variable approach, only because I expect it to be fixed in the future with an
Since the variable is tracking our own internal state of whether or not we initialized AWS
This is the solution I'm most heavily leaning toward, but if OPeNDAP BES is a big enough motivating case, I could see the workaround to release as much state as possible being fine. |
Describe your changes
The ROS3 VFD's AWS event loop group and host resolver were released only in an
atexit()handler on non-Windows platforms. Their threads are "managed" aws-c-common threads, so another aws-c-* user in the same process that joins all managed threads during its own shutdown waits forever for them. For example,Aws::ShutdownAPI()in the AWS C++ SDK does this, and OPeNDAP BES hangs when it unloads its modules after using the ROS3 VFD.H5FD__s3comms_term()(reached fromH5close()) now releases the event loop group and host resolver, so their threads exit.aws_s3_library_clean_up()stays in theatexit()handler. It also joins every managed thread in the process, including threads owned by other aws-c-* users, so calling it fromH5close()could block on them.aws_s3_library_init()and theatexit()registration now happen only once, so the ROS3 VFD can be used again afterH5close().atexit()handler is registered, andH5close()performs the full cleanup, guarded byRtlDllShutdownInProgress().The same change passed the ROS3 VFD CI on Ubuntu, macOS and Windows (Debug and Release) in my fork, including the
ros3,s3comms,h5lsandh5statS3 tests: https://github.com/hyoklee/hdf5/actions/runs/37722760418Issue ticket number (GitHub or JIRA)
None.
Checklist before requesting a review
🤖 Generated with Claude Code