#4821 Wrong Tcl_StatBuf used on MinGW

obsolete: 8.6b1.1
closed-fixed
5
2012-03-27
2011-04-17
Andy Goth
No

On MinGW, tcl.h typedefs Tcl_StatBuf to be struct stat, which contains a 32-bit st_size. A 64-bit st_size is assumed by tclWinFile.c. This results in incorrect [file size], etc., for 2+ gigabyte files. struct _stati64 should be used instead. I made this change in my local Tcl source tree and recompiled, and [file size] now works correctly.

See /mingw/include/sys/stat.h for the family of stat structs and the circumstances under which each is available.

This is on a 32-bit Windows XP machine.

Discussion

  • Jan Nijtmans

    Jan Nijtmans - 2011-04-17
    • assigned_to: vincentdarley --> nijtmans
     
  • Jan Nijtmans

    Jan Nijtmans - 2011-04-17

    I'll have a look

     
  • Jan Nijtmans

    Jan Nijtmans - 2011-04-18

    Fixed on all open branches.

     
  • Jan Nijtmans

    Jan Nijtmans - 2011-04-18
    • status: open --> open-fixed
     
  • Jan Nijtmans

    Jan Nijtmans - 2011-04-21

    _stati64 uses either a 32-bit time_t, either a 64-bit time_t depending
    on _USE_32BIT_TIME_T, while MSVC6 always uses a 32-bit
    time_t. So, in order to keep binary compatibility on all platforms,
    we should use _stat32i64 whenever this is available (VS2005+)

    Problem: not all mingw versions have already taken this
    over from VS2005, so in case encountering an old mingw
    version, we should provide our own version in tclWinPort.h.

    For VS2005+, this means a binary API change, because
    starting with this version the time_t type suddenly starts
    to be 64-bit, unless we define _USE_32BIT_TIME_T.

    Pat Thoyts, Any remarks?

     
  • Don Porter

    Don Porter - 2011-04-21

    I think these are new warnings from tclTest.c
    building Tcl 8.4 tip . Related to these changes?

    /home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c: In function ‘TeststatprocCmd’:
    /home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c:4660: warning: assignment from incompatible pointer type
    /home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c:4662: warning: assignment from incompatible pointer type
    /home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c:4664: warning: assignment from incompatible pointer type
    /home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c:4666: warning: assignment from incompatible pointer type
    /home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c:4676: warning: comparison of distinct pointer types lacks a cast

     
  • Jan Nijtmans

    Jan Nijtmans - 2011-04-21

    >I think these are new warnings from tclTest.c
    >building Tcl 8.4 tip . Related to these changes?

    Yes, it was related. Should be fixed now.

     
  • Jan Nijtmans

    Jan Nijtmans - 2011-10-13
    • status: open-fixed --> closed-fixed
     
  • Jan Nijtmans

    Jan Nijtmans - 2012-03-14
    • status: closed-fixed --> open-accepted
     
  • Jan Nijtmans

    Jan Nijtmans - 2012-03-14

    Re-opening. Reason: cygwin switched from using
    the /win directory for its build to the /unix
    directory, but then also starts to use the
    unix stat64 structure. cygwin tclsh can load
    and run Tcl extensions compiled with mingw,
    but those use a different struct for Tcl_StatBuf.
    So the problem described here re-appeard
    for cygwin ;-(

    Solution: make a special Tcl_StatBuf for
    cygwin's unix build only, which has
    exactly the same structure as _stat32i64
    (copy this from tclWinPort.h to tcl.h)

     
  • Jan Nijtmans

    Jan Nijtmans - 2012-03-27

    Should finally be fixed now for all branches

     
  • Jan Nijtmans

    Jan Nijtmans - 2012-03-27
    • status: open-accepted --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks