octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #41330] fopen (<fname>, "w") creates temp file


From: Philip Nienhuis
Subject: [Octave-bug-tracker] [bug #41330] fopen (<fname>, "w") creates temp file with different file name
Date: Fri, 24 Jan 2014 09:26:25 +0000
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:25.0) Gecko/20100101 Firefox/25.0 SeaMonkey/2.22.1

URL:
  <http://savannah.gnu.org/bugs/?41330>

                 Summary: fopen (<fname>, "w") creates temp file with
different file name
                 Project: GNU Octave
            Submitted by: philipnienhuis
            Submitted on: Fri 24 Jan 2014 10:26:24 AM CET
                Category: Libraries
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Philip Nienhuis
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

(Also present in 3.8.0 mingw mxe-cross-built)

Steps to reproduce:

- Put attached script tmpf.m & file template.ods into same subdir.
(tmpf.m reproduced below for clarity:

tmpdir = tmpnam
unpack ("template.ods", tmpdir, "unzip");
tmpfil = tmpnam
fid = fopen (tmpnam, "w+");
fclose (fid);
confirm_recursive_rmdir ("yes");
rmdir (tmpdir, "s")
)

- Run tmpf.m, note name of temp file <tmpfil> (e.g., /path/to/temp/dir/oct-3)

- Watch contents of temp directory: I get a file called oct-4 instead of
oct-3.

It turns out I can very reliably reproduce this on my XP and Win 7 boxes at
home.

Furthermore,

>> tmpfil = tmpnam
tmpfil = C:\Home\Philip\LOCALS~1\Temp\oct-21
>> fid = fopen (tmpnam)
fid = -1
>> fid = fopen (tmpnam, 'r')
fid = -1
>> fid = fopen (tmpnam, 'w')
fid =  3
>>


...gets me a temp file called 'oct-24" rather than "oct-21".

The effect is that unlinking temp files gets a bit hard, so over time the temp
dir gets cluttered with tens or hundreds of temp files.

As to reproducability:
Sometimes this works OK. But once some unknown condition ("nasal demon"?
thanks Jordi for that term!) has been triggered, the above behavior is
consistent, also over restarts of Octave.
(Sorry for guessing) I can't put a finger on it, but maybe it is due to the
unpack statement of the .ods file (effectively a plain .zip file with .ods
suffix). Or maybe it is related to a timing issue in the OS.

Is there a way to find out the file name associated with a particular file
handle, or to delete a file by its file handle? That would make it easier to
delete temp files and could be a good workaround for this bug.




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Fri 24 Jan 2014 10:26:24 AM CET  Name: tmpf.m  Size: 194B   By:
philipnienhuis

<http://savannah.gnu.org/bugs/download.php?file_id=30360>
-------------------------------------------------------
Date: Fri 24 Jan 2014 10:26:24 AM CET  Name: template.ods  Size: 7kB   By:
philipnienhuis

<http://savannah.gnu.org/bugs/download.php?file_id=30361>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?41330>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]