Skip to content

Commit

Permalink
Try to fix ASAN error
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatia committed Dec 18, 2024
1 parent 4723950 commit b1d8be7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
40 changes: 37 additions & 3 deletions tiledb/sm/query/readers/result_tile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ ResultTile::ResultTile(
coord_func_ = &ResultTile::zipped_coord;
}

ResultTile::~ResultTile() {
try {
// Wait for all tasks to be done
wait_all_attrs();
wait_all_coords();
} catch (...) {
return;
}
}

/* ****************************** */
/* API */
/* ****************************** */
Expand Down Expand Up @@ -130,7 +140,7 @@ void ResultTile::erase_tile(const std::string& name) {

// Handle attribute tile
for (auto& at : attr_tiles_) {
if (at.first == name) {
if (at.second.has_value() && at.first == name) {
at.second.reset();
return;
}
Expand Down Expand Up @@ -262,8 +272,32 @@ ResultTile::TileTuple* ResultTile::tile_tuple(const std::string& name) {
}

void ResultTile::wait_all_coords() const {
for (auto& coord_tile : coord_tiles_) {
coord_tile.second->fixed_tile().data_as<char>();
for (auto& at : coord_tiles_) {
auto& tile_tuple = at.second;
if (tile_tuple.has_value()) {
tile_tuple.value().fixed_tile().data();
if (tile_tuple.value().var_tile_opt().has_value()) {
tile_tuple.value().var_tile_opt().value().data();
}
if (tile_tuple.value().validity_tile_opt().has_value()) {
tile_tuple.value().validity_tile_opt().value().data();
}
}
}
}

void ResultTile::wait_all_attrs() const {
for (auto& at : attr_tiles_) {
const auto& tile_tuple = at.second;
if (tile_tuple.has_value()) {
tile_tuple.value().fixed_tile().data();
if (tile_tuple.value().var_tile_opt().has_value()) {
tile_tuple.value().var_tile_opt().value().data();
}
if (tile_tuple.value().validity_tile_opt().has_value()) {
tile_tuple.value().validity_tile_opt().value().data();
}
}
}
}

Expand Down
15 changes: 14 additions & 1 deletion tiledb/sm/query/readers/result_tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,16 @@ class ResultTile {
return validity_tile_.value();
}

/** @returns Var tile. */
const std::optional<Tile>& var_tile_opt() const {
return var_tile_;
}

/** @returns Validity tile. */
const std::optional<Tile>& validity_tile_opt() const {
return validity_tile_;
}

/** @returns Fixed tile. */
const Tile& fixed_tile() const {
return fixed_tile_;
Expand Down Expand Up @@ -457,7 +467,7 @@ class ResultTile {
DISABLE_MOVE_AND_MOVE_ASSIGN(ResultTile);

/** Default destructor. */
~ResultTile() = default;
virtual ~ResultTile();

/* ********************************* */
/* API */
Expand Down Expand Up @@ -746,6 +756,9 @@ class ResultTile {
/* Waits for all coord tiles results to be available */
void wait_all_coords() const;

/* Waits for all attr tiles results to be available */
void wait_all_attrs() const;

protected:
/* ********************************* */
/* PROTECTED ATTRIBUTES */
Expand Down

0 comments on commit b1d8be7

Please sign in to comment.