Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
4.7.1
-
None
Description
I was surprised to receive a warning from this code.
bool ok = storage->resize(offset + size); Q_ASSERT(ok); uchar *data = storage->map(offset, size);
The warning is this:
QFSFileEngine::map: Mapping a file beyond its size is not portable
This isn't mapping the file beyond its size. I looked into the code and found a problem with the stat cache.
QFSFileEngine caches stat results (which is probably a good thing) but it does not invalidate this cache when resizing the file. Hence, in my case, the file was stat'ed before it was resized so the map function was checking an invalid size.
Closing and re-opening the file can be used as a workaround.
Ideally the file engine would invalidate the stat cache (set d->tried_stat to false) so that another stat is done after file is resized. It may even be safe to just update the stat structure with the new size.