Skip to content
Tcl Source Code History Of Ticket 92564326a9
Login

History Of Ticket 92564326a9

Artifacts Associated With Ticket 92564326a9

  1. Ticket change [917ce6fcd7] (rid 162872) by wrenashe on 2018-05-08 07:02:43:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      We recently got "file operator leaks" on AIX from Tcl 8.5.19/8.6.3 which was built by ourselves on AIX for 32-bit Tcl target. 
      
      build@aixbuild 8>xlC_r -qversion
      IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)
      Version: 13.01.0003.0000
      
      The sympton was like,
      <-libc.a:opendir() = 3603f978		0.000000
      495.8273:        getdirent(161, 0x360ADD78, 4096) = 1024
      496.6565:        getdirent(161, 0x360ADD78, 4096) = 0
      ->libc.a:closedir(0x3603f978)
      <-libc.a:closedir() = 0		0.000000
      ->libc.a:opendir(0x35caf13c)
      498.2069:        getdirent(161, 0x360ADD78, 4096) = 116
      <-libc.a:opendir() = 3603f978		0.000000
      498.2097:        getdirent64(161, 0x360ADD78, 4096) = 160
      498.2100:        getdirent64(161, 0x360ADD78, 4096) = 0
      ->libc.a:closedir(0x3603f978)
      <-libc.a:closedir() = ffffffffffffffff		0.000000
      
      You can see closedir() fails at the end and then the file operator is leaked then.
      
      The problem is caused by closedir() call after readdir64() which is enabled by "-DHAVE_STRUCT_DIRENT64=1" instead of readdir() during the build.
      
      The warning is issued during the build.
      "/work/app/external/tcl8.5.19/unix/../unix/tclUnixFile.c", line 392.35: 1506-280 (W) Function argument assignment between types "struct dirdesc64*" and "struct dirdesc*" is not allowed.
      
      The suggestion is to align all the DIR operations in either 64-bit or 32-bit ones to avoid build warning and file operator leak in the runtime. Tcl now only has TclOSreaddir defined for readdir/readdir64().
      
      Tao
      
    5. foundin initialized to: "8.5.19 and above"
    6. is_private initialized to: "0"
    7. login: "wrenashe"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "f5e96bd3168d173a07f11b6f7040c085db1fb97d"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "wrenashe"
    14. subsystem initialized to: "37. File System"
    15. title initialized to:
      Open file descriptor leak: better align dir operations(opendir/readdir/closedir) all to either 64bit or 32bit ones.
      
    16. type initialized to: "Bug"
  2. Ticket change [372693da50] (rid 162884) by sebres on 2018-05-08 10:02:04:

    1. closedate changed to: "2458246.91810552"
    2. closer changed to: "sebres"
    3. icomment:
      Fixed in [85bcf84100] for both branches (8.5 / 8.6).
      
      Thanks Tao. Could you test it please for your AIX-system?
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
  3. Ticket change [21241ce9a0] (rid 162904) by wrenashe on 2018-05-09 02:12:28:

    1. closer changed to: "nobody"
    2. icomment:
      As the comments to "sebres added on 2018-05-08 10:02:04:"
      
      Sebres,
      
      Thanks for the prompt reply. I thought your fix was not completed one, you missed DIR/DIR64. I attached the partial patch based on my local 8.5.19 for your reference here(DIR to Tcl_Dir), the other two tclUnixFile.c and tclUnixFCmd.c files need a light update as well on where DIR is placed. I tag the bug with "rejected" and "pending" to drive the workflow.
      
      The changes to my local is built good on AIX and testing is passed.
      
      Index: tclUnixPort.h
      ===================================================================
      --- tclUnixPort.h	(revision 88561)
      +++ tclUnixPort.h	(working copy)
      @@ -59,10 +59,18 @@
       
       #ifdef HAVE_STRUCT_DIRENT64
       typedef struct dirent64	Tcl_DirEntry;
      +typedef DIR64			Tcl_Dir;
       #   define TclOSreaddir		readdir64
      +#   define TclOSopendir		opendir64
      +#   define TclOSrewinddir	rewinddir64
      +#   define TclOSclosedir	closedir64
       #else
       typedef struct dirent	Tcl_DirEntry;
      +typedef DIR		Tcl_Dir;
       #   define TclOSreaddir		readdir
      +#   define TclOSopendir		opendir
      +#   define TclOSrewinddir	rewinddir
      +#   define TclOSclosedir	closedir
       #endif
       
       #ifdef HAVE_TYPE_OFF64_T
      
    3. login: "wrenashe"
    4. mimetype: "text/plain"
    5. resolution changed to: "Rejected"
    6. status changed to: "Pending"
  4. Ticket change [169103fbc5] (rid 162923) by sebres on 2018-05-09 10:37:16:

    1. closedate changed to: "2458247.94254884"
    2. closer changed to: "sebres"
    3. icomment:
      Done.
      Thx again.
      
    4. login: "sebres"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
  5. Ticket change [c6bbe0bb44] (rid 162933) by wrenashe on 2018-05-10 01:51:01:

    1. assignee changed to: "sebres"
    2. closer changed to: "nobody"
    3. icomment:
      To be more clear,
      
       Modified generic/tclIntPlatDecls.h from [8993284278] to [1333869f36].
      
          12     12   
          13     13   #ifndef _TCLINTPLATDECLS
          14     14   #define _TCLINTPLATDECLS
          15     15   
          16     16   #ifdef __WIN32__
          17     17   #   define Tcl_DirEntry void
          18     18   #   define DIR void
                 19  +#   define Tcl_Dir void
          19     20   #endif
          20     21   
          21     22   #undef TCL_STORAGE_CLASS
      
      That "18   #   define DIR void" is suggested to removed as well.
      
    4. login: "wrenashe"
    5. mimetype: "text/plain"
    6. status changed to: "Pending"
  6. Ticket change [d0193745af] (rid 162943) by wrenashe on 2018-05-11 05:28:45:

    1. closedate changed to: "2458249.72830417"
    2. closer changed to: "wrenashe"
    3. login: "wrenashe"
    4. mimetype: "text/plain"
    5. status changed to: "Closed"
  7. Ticket change [d78504d17c] (rid 163737) by chw on 2018-06-02 11:26:26:

    1. closer changed to: "nobody"
    2. icomment:
      The introduction of "typedef DIR64 TclDIR" et.al. broke my builds on
      CentOS 5 x86 (and possibly others on 32 bit platforms, which usually do
      not have a DIR64 data type).
      
      A slightly modified autogoo helped, as can be seen in check-in
      
        https://www.androwish.org/index.html/info/6119b8ac2aee8411
      
      Still broader verification is required on different 32 bit POSIX platforms.
      
    3. login: "chw"
    4. mimetype: "text/plain"
    5. status changed to: "Pending"
  8. Ticket change [005b2b7138] (rid 163740) by bll on 2018-06-02 16:27:52:

    1. icomment:
      Related: 
          http://core.tcl.tk/tcl/info/02b58d5d040821ba
      
    2. login: "bll"
    3. mimetype: "text/plain"
  9. Ticket change [b390ae42fc] (rid 163743) by sebres on 2018-06-04 10:38:05:

    1. icomment:
      I don't think such deviation between dirent64/DIR64 (as in mentioned androwish commit now) is good idea at all.
      
      Because the documentation says about the declaration of "readdir64" pretty clear:
      <code><pre>
      struct dirent64 *readdir64 (DIR64 *DirectoryPointer);
      </pre></code>
      
      So how it may be possible at all, that HAVE_STRUCT_DIRENT64 is 1 and HAVE_DIR64 is not?
      How it is declared on your system?
      
    2. login: "sebres"
    3. mimetype: "text/plain"
  10. Ticket change [2ae53e4dac] (rid 163744) by chw on 2018-06-04 11:22:57:

    1. icomment:
      Linux/glibc x86_64 for example:
      
        /usr/include/dirent.h:
        ...
        #ifdef __USE_LARGEFILE64
        extern struct dirent64 *readdir64 (DIR *__dirp) __nonnull ((1));
        #endif
      
      There simply is no DIR64 data type.
      
    2. login: "chw"
    3. mimetype: "text/plain"
  11. Ticket change [5dd5945b66] (rid 163791) by sebres on 2018-06-04 14:10:00:

    1. icomment:
      You are right, thanks.
      
      I tried to find all possible constellations (as regards dirent.h, __USE_FILE_OFFSET64, __USE_LARGEFILE64 etc.),
      so I've rewritten it a bit (in opposite to the current fix from androwish):
      
      - Tcl_DirEntry and TclOSreaddir	are dependent on HAVE_STRUCT_DIRENT64;
      
      - TclDIR, TclOSopendir, TclOSrewinddir and TclOSclosedir on HAVE_DIR64;
      
      If I can assess the configure rules correctly, HAVE_DIR64 will set only if supported (and HAVE_STRUCT_DIRENT64 will set also);
      
      Thus fixed in [32babd8ff27c1141] for 8.5 (and merged into 8.6th).
      
      @wrenashe: Tao, could you please test the latest version on your system (as regards the subject, I mean the leaks).
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  12. Ticket change [c2b03341a1] (rid 163792) by jan.nijtmans on 2018-06-05 07:45:42:

    1. icomment:
      Thanks, sebres, for taking this!  For the 8.x line I agree with your approach. The reason: Using -D_LARGEFILE_SOURCE -D`$(getconf LFS_CFLAGS)` would affect all usage of off_t, the ones in 'struct stat' as well. So, it could lead to binary incompatibility on some platforms (however subtile). For 9.0 that's OK (even better) but for 8.x I'm a little bit reluctant to make that step already.
      
      So - indeed - all those #ifdef's make it a little bit complicated, but it fully preserves binary compatibility with earlier 8.x releases. Good work!
      
      So, +1 for merging it further (core-8-branch and trunk). We already have ticket [02b58d5d04] for cleaning up the code for 9.0, doing it the 'right' way (implementation not 100% finished yet, no TIP needed because it's implementation change only)
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  13. Ticket change [0d1d43aca4] (rid 163799) by sebres on 2018-06-05 09:14:55:

    1. closedate changed to: "2458274.88536078"
    2. closer changed to: "sebres"
    3. icomment: "Thus merged and I close the ticket. Thx, Jan."
    4. login: "sebres"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"