Skip to content

Commit

Permalink
Avoid seg faults with serialised csv objects
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnlaffan committed Sep 19, 2023
1 parent 5006825 commit 1445ffa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Biodiverse/BaseData.pm
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ sub new {
if ( defined $args{file} ) {
my $file_loaded;
$file_loaded = $self->load_file(@_);
# hack to avoid seg faults with csv objects
$file_loaded->get_groups_ref->delete_element_name_csv_object;
$file_loaded->get_labels_ref->delete_element_name_csv_object;

return $file_loaded;
}

Expand Down
11 changes: 11 additions & 0 deletions lib/Biodiverse/Common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,17 @@ sub get_csv_object {
return $csv;
}

# csv can cause seg faults when reloaded
# have not yet sorted out why
sub delete_element_name_csv_object {
my ($self) = @_;

state $cache_name = '_ELEMENT_NAME_CSV_OBJECT';
$self->delete_cached_value ($cache_name);

return;
}

sub get_element_name_csv_object {
my ($self) = @_;

Expand Down
4 changes: 4 additions & 0 deletions lib/Biodiverse/GUI/Project.pm
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ sub add_base_data {
$self->select_base_data($basedata_ref);
}

# hack to avoid seg faults with csv objects
$basedata_ref->get_groups_ref->delete_element_name_csv_object;
$basedata_ref->get_labels_ref->delete_element_name_csv_object;

$self->set_dirty();
return $basedata_ref;
}
Expand Down

0 comments on commit 1445ffa

Please sign in to comment.