From 5f5a7bbdd2bc3f5689711ce658c944ae639dae5c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 17 Jul 2021 22:00:52 +0200 Subject: [PATCH] Only call ftruncate() when size > 0 Either Boost or Linux really doesn't like it if you ftruncate() shared memory down to 0 bytes. --- CHANGELOG.md | 6 ++++-- src/common/audio-shm.cpp | 22 ++++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a493183a..9b490611 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,14 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed +- Fixed a regression from yabridge 3.4.0 where plugins with zero audio channels + would result in a crash. +- Fixed a regression from yabridge 3.4.0 where JUCE-based VST3 plugins might + cause **Ardour** or **Mixbus** to freeze in very specific circumstances. - Worked around a **REAPER** bug that would cause REAPER to not process any keyboard input when the FX window is active but the mouse is outside of the window. We now use the same validation used in `xprop` and `xwininfo` to find the host's window instead of always taking the topmost window. -- Fixed a regression from yabridge 3.4.0 where JUCE-based VST3 plugins might - cause **Ardour** or **Mixbus** to freeze. ## [3.4.0] - 2021-07-15 diff --git a/src/common/audio-shm.cpp b/src/common/audio-shm.cpp index 99dafd43..bc4acd40 100644 --- a/src/common/audio-shm.cpp +++ b/src/common/audio-shm.cpp @@ -21,10 +21,14 @@ AudioShmBuffer::AudioShmBuffer(const Config& config) shm(boost::interprocess::open_or_create, config.name.c_str(), boost::interprocess::read_write) { - shm.truncate(config.size); - buffer = - boost::interprocess::mapped_region(shm, boost::interprocess::read_write, - 0, config.size, nullptr, MAP_LOCKED); + // Apparently you get a `Resource temporarily unavailable` when calling + // `ftruncate()` with a size of 0 on shared memory + if (config.size > 0) { + shm.truncate(config.size); + buffer = boost::interprocess::mapped_region( + shm, boost::interprocess::read_write, 0, config.size, nullptr, + MAP_LOCKED); + } } AudioShmBuffer::~AudioShmBuffer() noexcept { @@ -44,10 +48,12 @@ void AudioShmBuffer::resize(const Config& new_config) { } config = new_config; - shm.truncate(config.size); - buffer = - boost::interprocess::mapped_region(shm, boost::interprocess::read_write, - 0, config.size, nullptr, MAP_LOCKED); + if (config.size > 0) { + shm.truncate(config.size); + buffer = boost::interprocess::mapped_region( + shm, boost::interprocess::read_write, 0, config.size, nullptr, + MAP_LOCKED); + } } AudioShmBuffer::AudioShmBuffer(AudioShmBuffer&& o) noexcept