[Interest] QSettings stale lock file

Koehne Kai Kai.Koehne at theqtcompany.com
Thu Feb 26 09:43:11 CET 2015



> -----Original Message-----
> From: interest-bounces+kai.koehne=theqtcompany.com at qt-project.org
> [mailto:interest-bounces+kai.koehne=theqtcompany.com at qt-project.org]
> On Behalf Of Frank Hemer
> Sent: Wednesday, February 25, 2015 5:24 PM
> To: interest at qt-project.org
> Subject: Re: [Interest] QSettings stale lock file
> 
> 
> On Wednesday 25 February 2015 07:25:41 Thiago Macieira wrote:
> > On Wednesday 25 February 2015 11:30:57 Frank Hemer wrote:
> > > On a windows7 professional, I'm using QSettings for the local user -
> > > the settings data is located on a roaming profile.
> > > Now I experience stale lock files xxx.ini.lock (zero bytes) that
> > > crash my application.
> > >
> > > There is no other process running that could access the qsettings!
> > >
> > > Can anyone shed some light on conditions that could cause this?
> >
> > I think you're confusing cause with consequence. The lock files don't
> > cause the crash; the crash is the cause for the files existing: the
> > process stopped before the lock file could be removed.
> 
> well - I should have explained in more detail.
> I was asking for the cause of the lock files to appear ... in many years I have
> never seen these (well, prob. bec. they are created and removed in some
> msecs). And looking at the code I expected to find some processID written
> there, but the size was zero.

The reason is that QSettings since Qt 5.4 use QSaveFile to write, which in turn uses QLockFile.

See also the 5.4.0 change log:

   * [QTBUG-21739] The locking mechanism inside QSettings has changed
     and is no longer compatible with the one of previous versions of
     Qt. There might be corruption if two applications running different
     versions of Qt are writing to the same config file at the same
     time. You must also now have write permissions in the directory
     containing the settings file in order to write settings.


Regards

Kai

> Right now it turned out that some user admin has changed the %appdata%
> env var for the win roaming profile to point onto a file server. I guess this
> kind of locking (QLockFile being used by QSettings) doesn't go very well with
> a samba?
> share.
> 
> Btw, the crash actually is a freeze ... the users called it a crash.
> 
> Best regards
> Frank
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list