Skip to content

Fix bug in Fortran dataset destructor #525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ To be released at a future time.

Description

- Fix a segfault in the dataset destructor
- Update supported Python versions to 3.10, 3.11, and 3.12
- Bump versions for upload/download-artifact Github Actions
- Add Client API functions to put, get, unpack,
Expand All @@ -15,8 +16,16 @@ Description
- Reenable move semantics and fix compiler warnings.

Detailed Notes

- Update supported Python versions to 3.10, 3.11, and 3.12
- For compilers that automatically call the dataset
destructor when the object goes out of scope, a segfault
was being triggered if the user was also explictly calling
the destructor. This was partially arising because
although we were freeing the underlying data and pointing to
NULL, the pointer to the object itself was never being
set to NULL. This has been fixed and should now be robust
to multiple calls to the destructor.
([PR525](https://github.com/CrayLabs/SmartRedis/pull/525))
- Update supported Python versions to 3.10, 3.11, and 3.12
([PR527](https://github.com/CrayLabs/SmartRedis/pull/527))
- Bump versions for upload/download-artifact Github Actions
([PR526](https://github.com/CrayLabs/SmartRedis/pull/526))
Expand Down
1 change: 1 addition & 0 deletions src/c/c_dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ extern "C" SRError DeallocateDataSet(void** dataset)
DataSet* d = reinterpret_cast<DataSet*>(*dataset);
delete d;
*dataset = NULL;
dataset = NULL;
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/fortran/dataset.F90
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ subroutine final_destructor(self)
type(dataset_type), intent(inout) :: self
integer :: code

if (c_associated(self%dataset_ptr)) code = dataset_deconstructor(self%dataset_ptr)
code = self%destructor()
end subroutine final_destructor

!> Destroy the dataset
Expand Down
7 changes: 6 additions & 1 deletion tests/fortran/client_test_dataset.F90
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ program main
integer :: ndims

integer :: i, j, k
type(dataset_type) :: dataset
type(dataset_type) :: dataset, retrieved_dataset
type(client_type) :: client

integer :: err_code
Expand Down Expand Up @@ -239,6 +239,11 @@ program main
if (result .ne. SRNoError) error stop
if (.not. exists) error stop 'existent dataset: FAILED'

! Test retrieval of dataset
result = client%get_dataset("test_dataset", retrieved_dataset)
if (result .ne. SRNoError) error stop
if (.not. exists) error stop 'get_dataset: FAILED'


write(*,*) "Fortran Dataset: passed"

Expand Down
Loading