Discussion:
[LyX/master] Remove unsafe method FileName::tempName()
Scott Kostyshak
2014-07-17 03:09:25 UTC
Permalink
commit f09a9fe2e60e4aeaca23b42b2bf30f5d64cfd9b1
Date: Mon Jun 9 13:05:50 2014 +0200
Remove unsafe method FileName::tempName()
FileName::tempName() created a new temp file name by using qt to create a
temporary file with a unique name, and then deleting that file and returning
the name. This was unsafe, since other processes or even other threads of the
running LyX could create files with the same name between deletion and then
using the temp name.
This is fixed by using the TempFile class instead. As a side effect, a few
cases where the temp files were not deleted after usage were fixed as well.
The only place that is still unsafe is createTmpDir().
I'm seeing a regression and git bisect led me back to here. Georg, can
you take a look to see if you can reproduce? If not, I will try to dig
deeper. The regression is that the attached document shows the date
before this commit for me but does not show the date (it shows nothing
where the date is inserted) as of this commit. Attached is the
document that leads to different outputs before and after this commit.
As for how I created the document, I can reproduce on Ubuntu 14.04
with the following:
1. Start a new document and wrote "Test: "
2. Go to Insert > File > External Material
3. Do not put anything in the "File" text box (I believe a "." is
automatically inserted).
4. Change "Template" to "Date".
5. Compile

Note that I'm not sure if this just resurfaced a different bug. I
think I heard somewhere that the "Date" external template was not
meant to be serious and was just put in as an example.

Scott
Georg Baum
2014-07-21 20:17:05 UTC
Permalink
Post by Scott Kostyshak
I'm seeing a regression and git bisect led me back to here. Georg, can
you take a look to see if you can reproduce? If not, I will try to dig
deeper. The regression is that the attached document shows the date
before this commit for me but does not show the date (it shows nothing
where the date is inserted) as of this commit. Attached is the
document that leads to different outputs before and after this commit.
As for how I created the document, I can reproduce on Ubuntu 14.04
1. Start a new document and wrote "Test: "
2. Go to Insert > File > External Material
3. Do not put anything in the "File" text box (I believe a "." is
automatically inserted).
4. Change "Template" to "Date".
5. Compile
Does the temporary file in the buffer temp dir contain the date output, or
is it just empty?
Post by Scott Kostyshak
Note that I'm not sure if this just resurfaced a different bug. I
think I heard somewhere that the "Date" external template was not
meant to be serious and was just put in as an example.
One difference to the old version is that the temp file does now exist when
the date command is executed (this is part of the thread-safetyness). This
should not matter, since the command reads

"python -tt $$s/scripts/date.py %d-%m-%Y > $$o"

but maybe it is locked somehow? Or something goes wrong with the extension
of the temp file (it might be different now if I made a mistake). Another
possibility is the one you mentioned: There might be another bug somewhere
which is now uncovered. Unless you find something I'll have a look, but I am
currently very busy.


Georg
Scott Kostyshak
2014-07-26 20:44:26 UTC
Permalink
On Mon, Jul 21, 2014 at 4:17 PM, Georg Baum
Post by Georg Baum
Does the temporary file in the buffer temp dir contain the date output, or
is it just empty?
It is empty.
Post by Georg Baum
One difference to the old version is that the temp file does now exist when
the date command is executed (this is part of the thread-safetyness). This
should not matter, since the command reads
"python -tt $$s/scripts/date.py %d-%m-%Y > $$o"
but maybe it is locked somehow? Or something goes wrong with the extension
of the temp file (it might be different now if I made a mistake). Another
possibility is the one you mentioned: There might be another bug somewhere
which is now uncovered. Unless you find something I'll have a look, but I am
currently very busy.
OK.

Scott
Scott Kostyshak
2014-07-26 20:48:01 UTC
Permalink
Post by Scott Kostyshak
On Mon, Jul 21, 2014 at 4:17 PM, Georg Baum
Post by Georg Baum
Does the temporary file in the buffer temp dir contain the date output, or
is it just empty?
It is empty.
To be clear, the file is not empty. The place where the date normally
would be is empty. It is attached.

Scott

Loading...