Opened 9 years ago
Closed 5 years ago
#5829 closed defect (wontfix)
[PATCH] Segfault when exiting with open HDF dataset
Reported by: | kikht | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | closed_because_of_github_migration |
Component: | GDAL_Raster | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: |
Description
Attached test program fails with segfault on exit(0);
call.
It happens because HDF library sets it's own cleanup procecure via atexit
. It is called before GDALDriverManager destructor which tries to close opened hdf file again, leading to segfault.
Provided patch disables HDF cleanup procedure by calling HDdont_atexit()
on driver initialization.
Attachments (3)
Change History (8)
by , 9 years ago
Attachment: | hdf_test.c added |
---|
comment:1 by , 9 years ago
I'm not too sure about what to do with that. The doc of HDdont_atexit() mentions that it prevents the HDF4 lib from freeing its buffers. This could be workaround by directly calling HPend() when unregistering the driver, but we don't know if another piece of code in the process (not GDAL) isn't going to use HDF4 lib again. This is a mess...
The safe side is to make sure you properly close with GDALClose() explicitely, or call GDALDestroyDriverManager() explicitely.
I'm not convinced that introducing a destructor function in GDAL was a good idea. It seems to cause more issues than it solves ones...
comment:2 by , 9 years ago
I've also sent patch to hdflib that fixes this issue from their side. Unfortunately they do not have public tracker.
comment:4 by , 9 years ago
Attached patch fixes HEshutdown function in HDF4. It frees error_stack and sets it to NULL, but misses to set error_top to 0. Some functions (e.g. HEPclear) rely on error_top value to detect stack existence, so it can lead to null pointer dereference.
The idea is to make HDF cleanup functions idempotent, but this patch fixes the only problem I've noticed.
comment:5 by , 5 years ago
Milestone: | → closed_because_of_github_migration |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.
Test program