Skip to content

Commit

Permalink
Don't copy FdTable::vms when cloning it, because the new FdTable will…
Browse files Browse the repository at this point in the history
… have an entirely new TaskSet

Also, tweak the code so we die if we discover an empty AddressSpace in `vms`.

Resolves #3475
  • Loading branch information
rocallahan committed Mar 30, 2023
1 parent 36b02f0 commit 1a1362e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/AddressSpace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,7 @@ AddressSpace::AddressSpace(Task* t, const string& exe, uint32_t exec_count)
}
}

// Does not copy the task set; the new AddressSpace will be for new tasks.
AddressSpace::AddressSpace(Session* session, const AddressSpace& o,
pid_t leader_tid, uint32_t leader_serial,
uint32_t exec_count)
Expand Down
7 changes: 6 additions & 1 deletion src/FdTable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,14 @@ void FdTable::update_syscallbuf_fds_disabled(int fd) {
// But tasks with the same VM might have different fd tables...
for (auto address_space : vms) {
RecordTask* rt = nullptr;
if (address_space.first->task_set().empty()) {
FATAL() << "Address space must have at least one task";
}
for (Task* t : address_space.first->task_set()) {
if (!t->session().is_recording()) {
return;
// We could return but we want to check that all our
// AddressSpaces have tasks (i.e. aren't dead/dangling)
break;
}
rt = static_cast<RecordTask*>(t);
if (!rt->already_exited()) {
Expand Down
4 changes: 3 additions & 1 deletion src/FdTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ class FdTable final : public HasTaskSet {

private:
FdTable() : fd_count_beyond_limit(0), last_free_fd_(0) {}
// Does not call the base-class copy constructor because
// we don't want to copy the task set; the new FdTable will
// be for new tasks.
FdTable(const FdTable& other) : fds(other.fds),
vms(other.vms),
fd_count_beyond_limit(other.fd_count_beyond_limit),
last_free_fd_(other.last_free_fd_) {}

Expand Down

0 comments on commit 1a1362e

Please sign in to comment.