[fpc-pascal] TIniFile crash
Ralf Quint
freedos.la at gmail.com
Tue Jul 29 20:26:21 CEST 2025
On 7/26/2025 2:05 PM, James Richters via fpc-pascal wrote:
>
> I’m having an issue with TIniFile,
> I have a pretty simple procedure,It deletes the old .ini file, waits
> for it to be gone, creates a new one, writes a bunch of variables to
> it, then frees it.It works 99% of the time, but 1% of the time it
> crashes right in the middle of writing the file.The previous one was
> really deleted because there is nothing left of the original after the
> crash, it contains only lines up to the failure.I just don’t see what
> I am doing wrong and I am hoping someone can help me figure out how to
> fix this.
> This is a single thread console application created with FreePascal
> with out Lazarus, and this file is not used by anything else.I just
> happened to catch it this time and I was sitting right here and
> nothing else was accessing Location.ini when the crash happened.
> This happens on multiple difference computers.Most of which have no
> purpose other than to run this one program, so there is never anything
> else even open in the system at all.
>
> Anyone have any idea why this is happening and how I might be able to
> prevent it?
> Below is the crash and related source code.
>
To narrow down where and why this would crash, you might want to try and
use some different procedure. Just going by a guts feeling, I guess your
problem is caused by this "waiting until the ini file is really deleted"
procedure.
To test this, please try to write the contents to the new .INI file,
deleting the old one and then rename the new one. I suspect that in this
order of things, it will not crash while writing to the new file...
If it does still crash, then the problem is within the writing of the
contents of the .ini file, otherwise this smells like some timing issue
introduced due to that waiting procedure, possibly in connection with
the OS file caching...
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20250729/6a22ed5f/attachment-0001.htm>
More information about the fpc-pascal
mailing list