[KDE/Mac] Review Request 125123: [WIP] CMake plugin: prevent the QFileSystemWatcher from hitting the open file limit

René J.V. Bertin rjvbertin at gmail.com
Wed Sep 23 14:13:12 UTC 2015



> On Sept. 23, 2015, 8:54 a.m., Gleb Popov wrote:
> > I suspect this is not relevant anymore for Qt 5 on OS X, because QFileSystemWatcher uses fsevents for tracking file changes there. But it is still a problem for FreeBSD, because it lacks efficient file changes notification facility. Using kqueue/kevent requires opening a file descriptor for every file being watched.

> on OS X[, because] QFileSystemWatcher uses fsevents for tracking file changes

That's supposedly the case, but are you sure it is always the case? For instance, when I start Qt Creator from a commandline I see this:

```
"/Applications/MacPorts/Qt5/Qt Creator.app/Contents/MacOS/Qt Creator" /opt/local/site-ports/devel/qt5-creator/files/patch-show-menubar-with-xcb.diff
QFileSystemWatcher: skipping native engine, using only polling engine
```

That message does not appear in the system.log when I start Creator via Launch Services.


- René J.V.


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/125123/#review85793
-----------------------------------------------------------


On Sept. 9, 2015, 10:18 p.m., René J.V. Bertin wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/125123/
> -----------------------------------------------------------
> 
> (Updated Sept. 9, 2015, 10:18 p.m.)
> 
> 
> Review request for KDE Software on Mac OS X and KDevelop.
> 
> 
> Repository: kdevelop
> 
> 
> Description
> -------
> 
> This is a confirmed bug in the 4.7 branch (and possibly in the KF5 version) where the cmake project importer can add (many) more paths to QFileSystemWatcher objects than the maximum supported number of open files (https://bugs.kde.org/show_bug.cgi?id=341551). On OS X at least this leads almost inevitably to a crash.
> 
> This patch prevents this by keeping track of the number of added paths, and by not adding more than a preconfigured maximum (determined empirically in this draft implementation). 
> The crash occurs in `folder = dynamic_cast<CMakeFolderItem*>(f);` in `CMakeCommitChangesJob::makeChanges()`; as an additional protection that function watches the `errno` variable for errors occurring during the `addPath()` operation; if an error is signalled, `folder` is not obtained by dynamic casting but by initialision a new `CMakeFolderItem`.
> `makeChanges()` also contains a few ASSERT statements that should remain effective even when building with `QT_NO_DEBUG`; the patch takes care of that as well.
> 
> I'm presenting this mostly for reference, in hope it may be useful for Kdevelop/KF5 too. In a real implementation the maximum number of patch watchers would of course be configurable.
> 
> 
> Diffs
> -----
> 
>   projectmanagers/cmake/cmakecommitchangesjob.cpp 7ce24fb 
>   projectmanagers/cmake/cmakemanager.h 19fc0c1 
>   projectmanagers/cmake/cmakemanager.cpp 2caecdb 
> 
> Diff: https://git.reviewboard.kde.org/r/125123/diff/
> 
> 
> Testing
> -------
> 
> On OS X 10.9.5 with kdelibs 4.14.11 and Qt 4.8.7 .
> m_MaxAllowedWatchedPaths is set to a value that is reasonably close to the limit where errors start occurring, and large enough to allow loading for instance kdepimlibs, kdepim and kdepim-runtime in a single session.
> 
> 
> Thanks,
> 
> René J.V. Bertin
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-mac/attachments/20150923/05809512/attachment.html>


More information about the kde-mac mailing list