public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47439] New: Fun with scratch files on Windows  MKTEMP only allows for 26 files
@ 2011-01-24 17:30 burnus at gcc dot gnu.org
  2011-01-25  9:48 ` [Bug fortran/47439] " jb at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-24 17:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47439

           Summary: Fun with scratch files on Windows  MKTEMP only allows
                    for 26 files
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: jvdelisle@gcc.gnu.org, jb@gcc.gnu.org


Reported by Claude Simone at
http://groups.google.com/group/comp.lang.fortran/msg/b1bf5ce50080e89e

Thread:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/8843f2317cb565cd


A) Not more than 26 temporary files are possible

To generate a temporay file, libgfortran/io/unix.c's tempfile calls the
system's mktemp, which according to Microsoft's API has the following property:

http://msdn.microsoft.com/en-us/library/34wc6k1f%28v=VS.80%29.aspx

"_mktemp preserves base and replaces the first trailing X with an alphabetic
character. _mktemp replaces the following trailing X's with a five-digit value;
this value is a unique number identifying the calling process, or in
multithreaded programs, the calling thread."

Hence, there are only "a" to "z" = 26 temporary files possible - at least
concurrently. Thus, for Windows systems, gfortran needs an own implementation
for mk(s)temp, which supports more. One possibility would be to change the BASE
handed to "mktemp".



B) Files are not unlinked

Newer Windows support for FILE_FLAG_DELETE_ON_CLOSE; cf. CreateFile Function at
http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx

See also http://msdn.microsoft.com/en-us/library/yeby3zcb%28v=VS.80%29.aspx for
"D" and "_O_TEMPORARY" in fopen and _wfopen.


However, in principle on exit libgfortran's
  static void __attribute__((destructor))
  cleanup (void)
should be called, which should delete files.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/47439] Fun with scratch files on Windows  MKTEMP only allows for 26 files
  2011-01-24 17:30 [Bug fortran/47439] New: Fun with scratch files on Windows MKTEMP only allows for 26 files burnus at gcc dot gnu.org
@ 2011-01-25  9:48 ` jb at gcc dot gnu.org
  2011-03-12 15:22 ` [Bug libfortran/47439] " fxcoudert at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jb at gcc dot gnu.org @ 2011-01-25  9:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47439

--- Comment #1 from Janne Blomqvist <jb at gcc dot gnu.org> 2011-01-25 09:28:14 UTC ---
Seems the reason for Windows _mktemp() behavior is due to replicating some
age-old BSD behavior. From the Linux mktemp(3) manpage:

BUGS
       Never use mktemp().  Some implementations follow 4.3BSD and replace
XXXXXX by the current process ID and a  single
       letter,  so  that  at most 26 different names can be returned.  Since on
the one hand the names are easy to guess,
       and on the other hand there is a race between testing whether the name
exists and opening the file, every  use  of
       mktemp() is a security risk.  The race is avoided by mkstemp(3).

(Needless to say, libgfortran use mkstemp() ifavailable, mktemp() is just a
fallback.)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/47439] Fun with scratch files on Windows  MKTEMP only allows for 26 files
  2011-01-24 17:30 [Bug fortran/47439] New: Fun with scratch files on Windows MKTEMP only allows for 26 files burnus at gcc dot gnu.org
  2011-01-25  9:48 ` [Bug fortran/47439] " jb at gcc dot gnu.org
@ 2011-03-12 15:22 ` fxcoudert at gcc dot gnu.org
  2011-03-19 13:39 ` fxcoudert at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2011-03-12 15:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47439

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
             Status|UNCONFIRMED                 |NEW
                URL|                            |http://gcc.gnu.org/ml/fortr
                   |                            |an/2011-03/msg00102.html
   Last reconfirmed|                            |2011.03.12 15:22:42
     Ever Confirmed|0                           |1

--- Comment #2 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> 2011-03-12 15:22:42 UTC ---
A patch for the first half of the PR can be found here:
http://gcc.gnu.org/ml/fortran/2011-03/msg00102.html


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/47439] Fun with scratch files on Windows  MKTEMP only allows for 26 files
  2011-01-24 17:30 [Bug fortran/47439] New: Fun with scratch files on Windows MKTEMP only allows for 26 files burnus at gcc dot gnu.org
  2011-01-25  9:48 ` [Bug fortran/47439] " jb at gcc dot gnu.org
  2011-03-12 15:22 ` [Bug libfortran/47439] " fxcoudert at gcc dot gnu.org
@ 2011-03-19 13:39 ` fxcoudert at gcc dot gnu.org
  2011-03-19 14:36 ` hjl.tools at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2011-03-19 13:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47439

--- Comment #3 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> 2011-03-19 12:09:34 UTC ---
Author: fxcoudert
Date: Sat Mar 19 12:09:27 2011
New Revision: 171178

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171178
Log:
    PR libfortran/47439

    * io/unix.c (tempfile): Work around poor mktemp() implementations.

    * gfortran.dg/scratch_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/scratch_1.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/unix.c


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/47439] Fun with scratch files on Windows  MKTEMP only allows for 26 files
  2011-01-24 17:30 [Bug fortran/47439] New: Fun with scratch files on Windows MKTEMP only allows for 26 files burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-03-19 13:39 ` fxcoudert at gcc dot gnu.org
@ 2011-03-19 14:36 ` hjl.tools at gmail dot com
  2011-03-19 14:58 ` fxcoudert at gcc dot gnu.org
  2011-03-19 14:59 ` fxcoudert at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: hjl.tools at gmail dot com @ 2011-03-19 14:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47439

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> 2011-03-19 14:30:37 UTC ---
On Linux/ia32, revision 171179 gave:

FAIL: gfortran.dg/scratch_1.f90  -O0  execution test
FAIL: gfortran.dg/scratch_1.f90  -O1  execution test
FAIL: gfortran.dg/scratch_1.f90  -O2  execution test
FAIL: gfortran.dg/scratch_1.f90  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/scratch_1.f90  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/scratch_1.f90  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/scratch_1.f90  -O3 -g  execution test
FAIL: gfortran.dg/scratch_1.f90  -Os  execution test


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/47439] Fun with scratch files on Windows  MKTEMP only allows for 26 files
  2011-01-24 17:30 [Bug fortran/47439] New: Fun with scratch files on Windows MKTEMP only allows for 26 files burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-03-19 14:36 ` hjl.tools at gmail dot com
@ 2011-03-19 14:58 ` fxcoudert at gcc dot gnu.org
  2011-03-19 14:59 ` fxcoudert at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2011-03-19 14:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47439

--- Comment #5 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> 2011-03-19 14:35:12 UTC ---
Author: fxcoudert
Date: Sat Mar 19 14:35:05 2011
New Revision: 171180

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171180
Log:
    PR libfortran/47439
    * gfortran.dg/scratch_1.f90: Adjust test.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/scratch_1.f90


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libfortran/47439] Fun with scratch files on Windows  MKTEMP only allows for 26 files
  2011-01-24 17:30 [Bug fortran/47439] New: Fun with scratch files on Windows MKTEMP only allows for 26 files burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-03-19 14:58 ` fxcoudert at gcc dot gnu.org
@ 2011-03-19 14:59 ` fxcoudert at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2011-03-19 14:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47439

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> 2011-03-19 14:36:13 UTC ---
(In reply to comment #4)
> FAIL: gfortran.dg/scratch_1.f90  -O0  execution test

Must be a limit on the number of concurrently open files (the test checks for
3000). Next commit fixed it.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-03-19 14:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-24 17:30 [Bug fortran/47439] New: Fun with scratch files on Windows MKTEMP only allows for 26 files burnus at gcc dot gnu.org
2011-01-25  9:48 ` [Bug fortran/47439] " jb at gcc dot gnu.org
2011-03-12 15:22 ` [Bug libfortran/47439] " fxcoudert at gcc dot gnu.org
2011-03-19 13:39 ` fxcoudert at gcc dot gnu.org
2011-03-19 14:36 ` hjl.tools at gmail dot com
2011-03-19 14:58 ` fxcoudert at gcc dot gnu.org
2011-03-19 14:59 ` fxcoudert at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).