Compare commits

...

5 Commits

Author SHA1 Message Date
Alex Sanchez-Stern b47ad3fad1
Merge 1252eba1cc into 2c83a256ae 2025-01-17 07:09:42 -04:00
Admiral H. Curtiss 2c83a256ae
Merge pull request #13277 from jordan-woyak/iowindow-debug-assert-fix
DolphinQt: Fix ASSERT failure in IOWindow in debug build.
2025-01-16 10:04:55 +01:00
Jordan Woyak c3f66e83e6 DolphinQt: Fix ASSERT failure in IOWindow in debug build. 2025-01-15 16:39:45 -06:00
Alex Sanchez-Stern 1252eba1cc Unlink shm file on close 2024-09-22 22:13:52 -07:00
Alex Sanchez-Stern d8d8b5a847
Don't unlink shared memory on Unix
Essentially adds the funcitonality from PR #6091 to Unix
platforms. This allows third party tools like DME and JuniorsToolbox
to access the shared memory region allowing them to manipulate game
memory for various functionality. To do this, keep the shared memory
object mapped to a name so that the other process can access it,
instead of unlinking it from the name right after creation. This might
leak files into the filesystem, like mentioned in
https://github.com/dolphin-emu/dolphin/pull/9834#discussion_r803123299,
but will only be one virtual file per dolphin so I think it's fine.
2024-09-09 18:30:34 -07:00
3 changed files with 7 additions and 4 deletions

View File

@ -124,6 +124,9 @@ private:
int m_shm_fd = 0; int m_shm_fd = 0;
void* m_reserved_region = nullptr; void* m_reserved_region = nullptr;
std::size_t m_reserved_region_size = 0; std::size_t m_reserved_region_size = 0;
#ifndef ANDROID
std::string m_seg_name;
#endif
#endif #endif
}; };

View File

@ -30,20 +30,20 @@ MemArena::~MemArena() = default;
void MemArena::GrabSHMSegment(size_t size, std::string_view base_name) void MemArena::GrabSHMSegment(size_t size, std::string_view base_name)
{ {
const std::string file_name = fmt::format("/{}.{}", base_name, getpid()); m_seg_name = fmt::format("/{}.{}", base_name, getpid());
m_shm_fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); m_shm_fd = shm_open(m_seg_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600);
if (m_shm_fd == -1) if (m_shm_fd == -1)
{ {
ERROR_LOG_FMT(MEMMAP, "shm_open failed: {}", strerror(errno)); ERROR_LOG_FMT(MEMMAP, "shm_open failed: {}", strerror(errno));
return; return;
} }
shm_unlink(file_name.c_str());
if (ftruncate(m_shm_fd, size) < 0) if (ftruncate(m_shm_fd, size) < 0)
ERROR_LOG_FMT(MEMMAP, "Failed to allocate low memory space"); ERROR_LOG_FMT(MEMMAP, "Failed to allocate low memory space");
} }
void MemArena::ReleaseSHMSegment() void MemArena::ReleaseSHMSegment()
{ {
shm_unlink(m_seg_name.c_str());
close(m_shm_fd); close(m_shm_fd);
} }

View File

@ -541,7 +541,7 @@ void IOWindow::ConnectWidgets()
const auto lock = m_controller->GetStateLock(); const auto lock = m_controller->GetStateLock();
m_reference->State(0.0); m_reference->State(0.0);
}); });
connect(this, &QWidget::destroyed, this, &IOWindow::TestOutputComplete); connect(this, &IOWindow::closeEvent, this, &IOWindow::TestOutputComplete);
connect(m_button_box, &QDialogButtonBox::clicked, this, &IOWindow::OnDialogButtonPressed); connect(m_button_box, &QDialogButtonBox::clicked, this, &IOWindow::OnDialogButtonPressed);
connect(m_devices_combo, &QComboBox::currentTextChanged, this, &IOWindow::OnDeviceChanged); connect(m_devices_combo, &QComboBox::currentTextChanged, this, &IOWindow::OnDeviceChanged);