Repository navigation
Conversation
FileWatcher::create() returns nullptr when the platform watcher cannot be created, for example when the per-user inotify instance limit is reached. ConfigStore only checked for that in update() and dereferenced the pointer when loading, saving, and clearing a file, which crashed the application. Skip watching in that case and log a warning instead, since the watcher only reloads changed files automatically.
|
One thing I'd like your opinion on: instead of guarding every use of As it is, this PR follows the null check that The alternative keeps the interface and the warning, and only touches namespace
{
// Used when the platform watcher cannot be created; nothing is ever reported as changed.
class NullFileWatcher : public vkShade::Platform::FileWatcher
{
public:
bool watch(const std::filesystem::path&) override { return false; }
void unwatch() override {}
bool changed() override { return false; }
};
}
// in create():
catch (const std::system_error& e) {
Logger::warn("File watcher unavailable, changed files will not be reloaded automatically: {}", e.what());
return std::make_unique<NullFileWatcher>();
}Then The trade-off is that I haven't tested this variant yet. Do you prefer it over the guards? I can switch this PR to it, or leave it as it is. |
vkShade crashes when the platform file watcher cannot be created.
FileWatcher::create()returnsnullptrif creating the watcher fails, for example when the per-user inotify instance limit (fs.inotify.max_user_instances, 128 by default) is exhausted.ConfigStore::update()already copes with a missing watcher, but loading, saving, and clearing a file dereferenced it. With the limit exhausted, vkShade loggedFailed to create file watcher: inotify_init1: Too many open filesthree times and then crashed.The change guards the four calls and logs a warning instead of an error, since the watcher only reloads changed files automatically:
File watcher unavailable, changed files will not be reloaded automatically: inotify_init1: Too many open files
Verification
Each process that loads the layer creates three watchers, so a few Vulkan processes at once (a launcher, the game, helpers) can use up the remaining instances on a busy desktop.