Skip to content
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

fix: potential memory leaks #248

Merged
merged 4 commits into from
Dec 19, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -559,7 +559,10 @@ void eventsChecker::ZEeventsChecker::checkForDeadlock(
// Form the dependency in the DAG
for (uint32_t i = 0; i < numWaitEvents; i++) {
auto it = eventToDagID.find(phWaitEvents[i]);

if (it == eventToDagID.end()) {
std::cerr << "Warning: phWaitEvents {" << phWaitEvents[i] << "} might be an invalid event in call to " << zeCallDisc << std::endl;
return;
}
uint32_t dagID = it->second;
if (dagID == invalidDagID) {
// Create a new node in the DAG for this wait event. That action will be created some time in the future.
8 changes: 6 additions & 2 deletions third_party/xla/ordered_set.h
Original file line number Diff line number Diff line change
@@ -56,12 +56,16 @@ class OrderedSet {
// set.
void Erase(T value) {
auto it = value_to_index_.find(value);
assert(it != value_to_index_.end());
if (it == value_to_index_.end()) {
std::cerr << "Value not found in OrderedSet" << std::endl;
exit(0);
}

auto index = it->second;
// Since we don't want to move values around in `value_sequence_` we swap
// the value in the last position and with value to be deleted and then
// pop_back.
value_to_index_[value_sequence_.back()] = it->second;
value_to_index_[value_sequence_.back()] = index;
std::swap(value_sequence_[it->second], value_sequence_.back());
value_sequence_.pop_back();
value_to_index_.erase(it);