Skip to content
Tcl Source Code History Of Ticket 3598300fffffffffffffffffffffffffffffffff
Login

History Of Ticket 3598300fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 3598300fffffffffffffffffffffffffffffffff

  1. Ticket change [36ae30fc68] (rid 107153) by roflz on 2012-12-24 08:14:41:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      tcl.h typedefs Tcl_StatBuf to struct stat/stat64 but does not include <sys/stat.h>
      
      this leads to compilation error in tclCmdAH.c because the storage size of variables of type Tcl_StatBuf is unknown.
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "roflz"
    10. subsystem initialized to: "None"
    11. title initialized to: "unix: tcl.h does not include sys/stat.h"
    12. type initialized to: "Bug"
  2. Ticket change [2972409523] (rid 88871) by roflz on 2012-12-24 15:15:07:

    1. assignee changed to: "stwo"
  3. Ticket change [1df823eab0] (rid 90899) by ferrieux on 2012-12-24 16:44:58:

    1. icomment:
      The unix-dependent includes come through tclUnixPort.h, included (through tclPort.h) by tclInt.h.
      So it is not as plain as a failure to include an obviously needed system header, but rather some ifdeffery that fails in this specific case (that I cannot reproduce). Any specific info re the OS and/or configure/-D flags ?
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  4. Ticket change [766accbc5f] (rid 105587) by roflz on 2012-12-24 20:02:45:

    1. icomment:
      this was experienced using musl libc 0.9.8 on i386
      since musl always uses LARGEFILE64, it #defines stat64 stat
      
      https://github.com/rofl0r/sabotage/commit/70807c9a16ef053b5bb432c69bccb29da27b1b10
      
      
    2. login: "roflz"
    3. mimetype: "text/plain"
    4. username: "roflz"
  5. Ticket change [af952428aa] (rid 97838) by ferrieux on 2012-12-24 23:45:57:

    1. icomment:
      Please attach the Makefile generated by Tcl's configure in this environment.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  6. Add attachment "Makefile.tcl" [29a3ad9af6] (rid 88900) by roflz on 2012-12-25 00:21:52.

  7. Ticket change [68f45e02f2] (rid 103155) by roflz on 2012-12-25 00:21:52:

    1. icomment:
      
      
      File Added - 458329: Makefile.tcl
      
      
      
    2. login: "roflz"
    3. mimetype: "text/plain"
    4. username: "roflz"
  8. Ticket change [dbda6c5a97] (rid 108032) by roflz on 2012-12-25 00:36:30:

    1. icomment:
      here's the relevant header part in musl libc:
      http://git.musl-libc.org/cgit/musl/tree/include/sys/stat.h#n98
      
      i added -D_GNU_SOURCE to the CFLAGS when launching configure, so this part got visible.
      tcl.h takes the typedef struct stat64 Tcl_StatBuf route. however without seeing the macro in sys/stat.h this cannot succeed, because stat64 is only a macro.
      
      
    2. login: "roflz"
    3. mimetype: "text/plain"
    4. username: "roflz"
  9. Ticket change [2038ae7fbc] (rid 91281) by ferrieux on 2012-12-25 01:23:46:

    1. icomment:
      So what ? Now your sys/stat.h is included, and stat64 gets mapped to stat, Tcl ends up needing a "struct stat" somewhere. I assume it is in <bits/stat.h> as in most unices, isn't it.
      
      To make this exchange more efficient, please provide the generated Makefile without any tweaks.
      Patching tcl.h or forcing CFLAGS sound  brittle ; better fix the root problem in the configure logic.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  10. Ticket change [7623b2aa4f] (rid 105520) by ferrieux on 2012-12-25 01:24:33:

    1. icomment:
      Ok, just seen the attachment, sorry ;)
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  11. Ticket change [3fb453edb5] (rid 121512) by ferrieux on 2012-12-25 01:26:53:

    1. icomment:
      Still, there might be a side effect to -D_GNU_SOURCE. Please give the vanilla Makefile, the one lacking HAVE_SYS_STAT.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  12. Ticket change [d961a06445] (rid 107599) by roflz on 2012-12-25 02:25:38:

    1. icomment:
      i never used any other Makefile
      adding -D_GNU_SOURCE to CFLAGS is something i automatically do always
      
      so it was not added specifically to circumvent some problems here.
      
      this is the exact Makefile that causes the build failure.
      
      
    2. login: "roflz"
    3. mimetype: "text/plain"
    4. username: "roflz"
  13. Ticket change [e16815aec0] (rid 87440) by roflz on 2012-12-25 02:28:31:

    1. icomment:
      musl's sys/stat.h includes an arch specific bits/stat.h that provides the actual definition of struct stat.
      http://git.musl-libc.org/cgit/musl/tree/arch/i386/bits/stat.h
      
      however it is not legal to include bits/stat.h directly, this is an internal header!
      if you do this, that would explain the breakage.
      
      
      
    2. login: "roflz"
    3. mimetype: "text/plain"
    4. username: "roflz"
  14. Ticket change [3813b3ab78] (rid 112143) by roflz on 2012-12-25 02:41:37:

    1. icomment:
      looking at tclUnixPort.h, it appears to me that sys/stat.h should be included before any stat-related ifdeffery
      there is code that defines things to be stat64, but since sys/stat.h is included later, the stat64 macro does not get expanded.
      
      
    2. login: "roflz"
    3. mimetype: "text/plain"
    4. username: "roflz"
  15. Ticket change [be53528458] (rid 102054) by ferrieux on 2012-12-25 07:40:53:

    1. icomment:
      > it is not legal to include bits/stat.h directly,
      > this is an internal header! -if you do this,
      > that would explain the breakage
      
      Ahem. Do you realize that this is the deed of (your/musl's) sys/stat.h ? Tcl just includes <sys/stat.h> just as everybody else.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  16. Ticket change [2388996c89] (rid 130956) by ferrieux on 2012-12-25 07:43:51:

    1. icomment:
      >looking at tclUnixPort.h, it appears to me that sys/stat.h should be
      >included before any stat-related ifdeffery
      >there is code that defines things to be stat64, but since sys/stat.h is
      >included later, the stat64 macro does not get expanded.
      
      Red herring. This code is just a pair of prototypes, passing opaque pointers. Even if I agree that they don't benefit from the macro, there is no harm done beyond a possible warning.
      
      If you want to proceed on this, please give the error message that you go when trying to compile with the vanilla Makefile generated by configure (not the one tweaked with whatever habits you have).
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  17. Ticket change [14c173270d] (rid 124451) by roflz on 2012-12-25 08:19:39:

    1. icomment:
      i mean this part here
      
      #elif defined(HAVE_STRUCT_STAT64)
      #   define TclOSstat            stat64
      #   define TclOSlstat           lstat64
      #else
      #   define TclOSstat            stat
      #   define TclOSlstat           lstat
      #endif
      
      the inclusion of stat.h comes later
      so whatever this tries to do, it doesn't see the stat64 macro and thus may fail.
      it is probably not related to the error i'm seeing.
      
      however it is very likely that the problem we're facing here has the same cause:
      tcl.h gets included before <sys/stat.h>, so the macro doesnt get expanded
      and the compiler fails to find the struct stat64.
      
      
    2. login: "roflz"
    3. mimetype: "text/plain"
    4. username: "roflz"
  18. Ticket change [e99ef7c38c] (rid 104845) by roflz on 2012-12-25 08:25:17:

    1. icomment:
      again i have not tweaked anything.
      this is the Makefile that gets created when running CFLAGS=-D_GNU_SOURCE ./configure.
      i never used anything else.
      it is perfectly legal to define _GNU_SOURCE, the libc is free to do it automatically for example by defining it in features, and so am i.
      since stat64 is completely non-standard, the implementation is free to define it as macro so you better make sure it works, by putting the inclusion of sys/stat.h before your typedefs.
      
      
    2. login: "roflz"
    3. mimetype: "text/plain"
    4. username: "roflz"
  19. Ticket change [307922ff69] (rid 93263) by roflz on 2012-12-25 08:30:21:

    1. icomment:
      here's the bug: tclPort.h
      
      
      #include "tcl.h"
      #if !defined(_WIN32)
      #   include "tclUnixPort.h"
      #endif
      
      
      it should include tclUnixPort.h before tcl.h, problem solved
      
      and for maximum portability put the include block in tclUnixport before any typedefs and macro definitions
      
      
    2. login: "roflz"
    3. mimetype: "text/plain"
    4. username: "roflz"
  20. Ticket change [8d8d3e1c87] (rid 127950) by ferrieux on 2012-12-25 08:43:54:

    1. assignee changed to: "nijtmans"
    2. icomment:
      Transferring to Jan Nijtmans, who did a similar move in a specific case (cygwin).
      Jan, any comment on the side-effects you feared, so that you didn't generalize ?
      (I'm referring to ad7cfb6ee3 where you moved tclWinPort above tcl.h, which looks like a good idea of wider applicability ;)
      
      
    3. login: "ferrieux"
    4. mimetype: "text/plain"
    5. username: "ferrieux"
  21. Ticket change [77fccdf7f2] (rid 89873) by nijtmans on 2012-12-25 19:16:44:

    1. foundin changed to: "obsolete: 8.5.13"
    2. icomment:
      > Jan, any comment on the side-effects you feared, so that you didn't
      > generalize ?
      Well, that change was for fixing a compiler warming with mingw, not
      for cygwin, but I agree with your analysis. It would be good to
      include sys/stat.h before tcl.h. The problem with this is
      the compat/*.h files, which currently need tcl.h to be
      included first. On cygwin/linux/solaris those are not used,
      so the move would be safe. But on older systems .....
      
      Another remark: The inclusion order didn't change
      between Tcl 8.5 and 8.6 (I can see in Makefile.tcl
      that the error occurred in 8.6, but I am assuming
      the same 'bug' is in 8.5 as well).
      
      The best solution here might be to move the
      sys/stat.h include from tcl*Port.h to tclInt.h.
      See:
         <http://core.tcl.tk/tcl/info/02a51cbb69>
      That has the least probability to break
      on any other platform.
      
      rofl0r, Alex, would that work for you? Any
      problems you can see with this change?
      
      
    3. login: "nijtmans"
    4. mimetype: "text/plain"
    5. subsystem changed to: "52. Portability Support"
    6. username: "nijtmans"
  22. Ticket change [7054fcdddf] (rid 100458) by ferrieux on 2012-12-26 00:53:50:

    1. icomment:
      Sorry, but digging a platform-specific header out and sticking it on top of the main generic one doesn't sound like a solid basis... Instead, I'd rather understand in detail why some parts of tcl*Port (like the compat/ ones) depend on being after tcl.h, and either stop this dependency, or move them in a separate file, to be included after tcl.h
      
      Can you please give these details (or just the kind of macros from tcl.h that are involed) ?
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  23. Ticket change [12b2914098] (rid 124090) by dgp on 2012-12-28 02:56:53:

    1. icomment:
      Only skimming the comments here.  One thing to keep in mind
      with any editing of the #include dependency graph is to preserve
      the goals of the 8.5 era "header reform."  See 922727.
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  24. Ticket change [39062eaa2a] (rid 112317) by nijtmans on 2012-12-28 03:25:53:

    1. icomment:
      Thanks, Don! But I'm fully aware of this header reform, and I
      don't think that my latest suggestions violatest this:
      <http://core.tcl.tk/tcl/info/dcbf22ad99>
      I don't see any danger in this, but please put in your view!
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  25. Ticket change [30709ac429] (rid 93254) by roflz on 2012-12-28 03:57:56:

    1. icomment:
      thanks njitmans for picking this up. however your fix is only a workaround this specific issue, but it still leaves everything else broken.
      this should be fixed properly by including all system headers before doing anything that depends on the types and other things defined in those headers, as ferrieux correctly noted.
      
      njitmans: i think it would help if you could answer ferrieux' question:
      "Can you please give these details (or just the kind of macros from tcl.h
      that are involed) ?"
      
      
    2. login: "roflz"
    3. mimetype: "text/plain"
    4. username: "roflz"
  26. Ticket change [5242f0d783] (rid 126284) by ferrieux on 2012-12-28 04:03:25:

    1. icomment:
      rofl0r, sorry for not keeping you up to date on this, but what you see on the trunk is only half of the fix (killing the bad dependencies). The second half (the actual permutation, putting sys headers first) did occur in a separate branch that Jan created: http://core.tcl.tk/tcl/info/dcbf22ad99
      
      I assume it will soon be merged to trunk if proven harmless (meaning: test on just about every alien OS too ;)
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  27. Ticket change [c8329f3987] (rid 122065) by ferrieux on 2013-01-13 17:07:41:

    1. icomment:
      Jan, Don, anything against merging dcbf22ad99 into 8.6 trunk ?
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  28. Ticket change [aa93d90859] (rid 100948) by nijtmans on 2013-01-13 19:31:18:

    1. assignee changed to: "andreas_kupries"
    2. icomment:
      I'm OK with that, but I still would like to hear Andreas' answer first before doing that.
      
      Therefore, assigning to Andreas for now.
      
      
    3. login: "nijtmans"
    4. mimetype: "text/plain"
    5. username: "nijtmans"
  29. Ticket change [64ade3acfa] (rid 92807) by dkf on 2013-01-14 03:36:46:

    1. icomment:
      I thought we'd managed to make it so that the definition wasn't needed in tcl.h. Might've been wrong on that though. :-)
      
      No objection in principle, provided it builds on Windows with MSVC (since it should work just fine on all POSIX systems).
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  30. Ticket change [b3195b2586] (rid 98459) by nijtmans on 2013-01-14 17:07:31:

    1. icomment:
      > I thought we'd managed to make it so that the definition wasn't needed in
      > tcl.h. Might've been wrong on that though. :-)
      I don't think you are wrong, but still it would be nice to test it on
      at least one ancient UNIX system,  like IRIX, HP-UX or SunOS-4.
      
      I would prefer to put it in 8.5, so it's simple to bubble-up to
      higher releases. The reason is just practical: There is no
      hurry for Tcl 8.6.1, so I see no hurry to rush this into 8.6
      first and then backport. A few weeks for Andreas to
      do some additional testing is fine with me.
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  31. Ticket change [1b268c370d] (rid 123095) by andreas_kupries on 2013-01-15 00:19:07:

    1. icomment:
      I saw the notifications for this thread coming through during the weekend.
      
      As an 8.6 build was scheduled for Sunday night I moved that to the branch in question, i.e.
      * bug-3598300
      
      This branch failed to build _everywhere_. I will give examples below for Linux, and AIX.
      
      Linux:
      
      EXEC ERROR: In file included from /home/andreask/dbn/lba/GlobalBuildArena/builds/linux-ix86/tcl/unix/../generic/tclPort.h:23,
      EXEC ERROR:                  from /home/andreask/dbn/lba/GlobalBuildArena/builds/linux-ix86/tcl/unix/../generic/tclInt.h:36,
      EXEC ERROR:                  from /home/andreask/dbn/lba/GlobalBuildArena/builds/linux-ix86/tcl/unix/../generic/regcustom.h:33,
      EXEC ERROR:                  from /home/andreask/dbn/lba/GlobalBuildArena/builds/linux-ix86/tcl/unix/../generic/regguts.h:36,
      EXEC ERROR:                  from /home/andreask/dbn/lba/GlobalBuildArena/builds/linux-ix86/tcl/unix/../generic/regcomp.c:33:
      EXEC ERROR: /home/andreask/dbn/lba/GlobalBuildArena/builds/linux-ix86/tcl/unix/../unix/tclUnixPort.h:630: error: syntax error before âstructâ
      EXEC ERROR: /home/andreask/dbn/lba/GlobalBuildArena/builds/linux-ix86/tcl/unix/../unix/tclUnixPort.h:630: error: syntax error before âtime_tâ
      EXEC ERROR: /home/andreask/dbn/lba/GlobalBuildArena/builds/linux-ix86/tcl/unix/../unix/tclUnixPort.h:631: error: syntax error before âstructâ
      EXEC ERROR: /home/andreask/dbn/lba/GlobalBuildArena/builds/linux-ix86/tcl/unix/../unix/tclUnixPort.h:631: error: syntax error before âtime_tâ
      EXEC ERROR: /home/andreask/dbn/lba/GlobalBuildArena/builds/linux-ix86/tcl/unix/../unix/tclUnixPort.h:649: error: syntax error before âintâ
      EXEC ERROR: make: *** [regcomp.o] Error 1
      
      AIX fails at the same location, with slightly different messaging.
      
      EXEC ERROR: "/home/andreask/dbn/lba/GlobalBuildArena/builds/aix-rs6000/tcl/unix/../unix/tclUnixPort.h", line 630.39: 1506-277 (S) Syntax error: possible missing ')' or ','?
      EXEC ERROR: "/home/andreask/dbn/lba/GlobalBuildArena/builds/aix-rs6000/tcl/unix/../unix/tclUnixPort.h", line 630.1: 1506-485 (S) Parameter declaration list is incompatible with declarator for EXTERN.
      EXEC ERROR: "/usr/include/grp.h", line 153.17: 1506-007 (S) "struct group" is undefined.
      EXEC ERROR: "/usr/include/grp.h", line 165.17: 1506-007 (S) "struct group" is undefined.
      EXEC ERROR: make: *** [regcomp.o] Error 1
      
      So, at this point the branch does not seem to be ready for merging.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  32. Ticket change [61371aaf8a] (rid 92207) by nijtmans on 2013-01-15 02:59:28:

    1. icomment:
      Well, that's embarassing   ;-(   Should be fixed now. In tclUnixPort.h
      there were still some usages of EXTERN and CONST, which depended on tcl.h
      
      Andreas, can I bother you again to build the "bug-3598300" branch?  Thanks!
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  33. Ticket change [ca0cf1acb3] (rid 122395) by andreas_kupries on 2013-01-15 03:24:29:

    1. icomment:
      I will set things up for another trial this night.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  34. Ticket change [0e2d03d5fb] (rid 94563) by andreas_kupries on 2013-01-16 00:16:51:

    1. icomment:
      Ok. tclsh was built on all my platforms now. The only thing which tripped me is that the branch is apparently off Tcl 8.5, and I tried to build it for AT 8.6, so the overall build failed, with Tk complaining about wanting 8.6 and having only 8.5.
      
      But the tclsh itself was build fine.
      Confirmed its existence on all machines.
      Works too, trying 'info patchlevel'.
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  35. Ticket change [1b3c0692ab] (rid 123111) by nijtmans on 2013-01-16 00:42:31:

    1. assignee changed to: "nijtmans"
    2. closedate changed to: "2013-01-15T17:42:31"
    3. closer changed to: "nijtmans"
    4. icomment:
      Fixed in core-8-5-branch and trunk now.
      
      Thanks! Andreas!
      
      
    5. login: "nijtmans"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
    9. username: "nijtmans"
  36. Ticket change [cc8fee8dbf] (rid 95719) by dkf on 2013-01-16 23:02:16:

    1. icomment:
      Appears to break OSX Leopard. Still investigating…
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  37. Ticket change [70032bb5e6] (rid 100403) by dkf on 2013-01-17 07:30:34:

    1. icomment:
      As far as I can tell, the problem is that there's a mismatch in between the use of 'struct stat' somehow in the code and the fact that we're using stat64() and lstat64() on OSX Leopard. This is in turn overwriting part of the stack it shouldn't (again: hypothesis) which is causing a pointer to a legit Tcl_Obj (in the encoding system initialization) to get turned into a NULL; for obvious reasons, applying a Tcl_GetString() to NULL (this is inside the path concatenation code as it happens) causes a crash.
      
      I emphasize that this is just supposition based on examining the backtrace at the point where the crash happens, together with the observation that I've only just recently started getting compile time warnings about the wrong type being used with stat64 and lstat64. The rest is a guess, but could so easily happen! (If this is true, it would explain why other developers aren't seeing the problem: they're not getting the type mismatch in the first place.)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  38. Ticket change [2499261465] (rid 131138) by dkf on 2013-01-17 07:38:57:

    1. icomment:
      Just checked the placement of variables on the stack; getting the wrong type for Tcl_StatBuf would indeed cause the crash, as the OS would write as if it was a 'struct stat64' whereas Tcl was compiled as if it was a 'struct stat'. (The other variable just happens to be placed a little bit after on the stack, within stomping range.)
      
      While this is annoying, it's at least clear what the problem *is* now!
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  39. Ticket change [b67a3abc50] (rid 125430) by andreas_kupries on 2013-01-17 07:49:38:

    1. icomment:
      Reopening the bug now ...
      AS OSX build box is snow leopard, with options set for leopard as min compat version. The older 8.4 build is done on tiger.
      
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. resolution changed to: "None"
    5. status changed to: "Open"
    6. username: "andreas_kupries"
  40. Ticket change [f4d7034f32] (rid 129992) by dkf on 2013-01-17 08:09:02:

    1. closedate changed to: "2013-01-17T01:09:02"
    2. closer changed to: "dkf"
    3. icomment:
      Problem commit identified as 8abba84224, appears to be due to swapping of order of include of tcl.h and tclUnixPort.h in tclPort.h (!!!!) which causes OSX Leopard (but not later versions) to get the wrong type of 'struct stat' used. The logic for that was gnarly (and hacked around quite a bit) but the key point is that there is a decision in tcl.h as to which stat API to use.
      
      According to comments in the code, it's not done in configure so as to allow for support for fat binaries (which have multiple architectures in the same object file). I vaguely remember Dan Steffen — or maybe Jim Ingham, as it was a long time ago — having a hand in the hacking of this, because at the time I used a totally different architecture.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "dkf"
  41. Ticket change [cd80ef26d1] (rid 95901) by dkf on 2013-01-17 08:09:33:

    1. resolution changed to: "None"
    2. status changed to: "Open"
  42. Ticket change [9f978182c7] (rid 96664) by nijtmans on 2013-01-17 15:40:28:

    1. assignee changed to: "dkf"
    2. icomment:
      This is serious enough to revert this on core-8-5-branch and trunk. Did that now, and placed a
      include <sys/stat.h> before <tcl.h> in every source file that uses Tcl_StatBuf. That should
      work a sufficient workaround for this bug, until this is investigated/worked out further.
      
      Thanks Donal, assigning to you now, hoping you can shine some more light on it.
      
      
    3. login: "nijtmans"
    4. mimetype: "text/plain"
    5. username: "nijtmans"
  43. Ticket change [a5f635976e] (rid 98519) by dkf on 2013-01-17 15:58:19:

    1. icomment:
      The problem was that in *some* circumstances (but not all), tcl.h is computing #defs that tclUnixPort.h requires to do the right thing w.r.t. picking up system structure definitions. I just happened to be on one of those platforms, which helped a lot for tracking the problem down. It looked a lot like the code was just going completely crazy though. :-) I spent quite a suspecting that the Tcl_Obj memory allocation system was at fault (it was innocent).
      
      The crazy thing is that tclPort.h is usually a file I completely ignore, as I "know" that it just includes the correct platform-specific portability file. Which just goes to show that what I "know" is sometimes wrong…
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  44. Ticket change [bb1a5caeb4] (rid 129423) by dkf on 2013-01-17 16:14:32:

    1. icomment:
      The branch minimal-fix-for-3598300-problems is as small a fix for the problems as I could make; with it, I can run scripts and work interactively once more.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  45. Ticket change [c10dae6eed] (rid 111260) by nijtmans on 2013-01-17 17:23:27:

    1. icomment:
      >The branch minimal-fix-for-3598300-problems
      That's effectively the same as what I did on core-8-5-branch and trunk ;-(
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  46. Ticket change [e0593f9dac] (rid 115175) by dkf on 2013-01-17 18:37:06:

    1. icomment:
      I'm happy to close my branch; I just wanted to get recorded exactly what I meant without any other changes. :-)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  47. Ticket change [385f18ada5] (rid 112198) by dkf on 2013-01-17 20:31:14:

    1. icomment:
      BTW, is there a reason why tclWinPort.h is before tcl.h in tclPort.h? 
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  48. Ticket change [f272cf38e7] (rid 109538) by ferrieux on 2013-01-17 20:34:23:

    1. icomment:
      Hum, the way I understand it, it is the other way around.
      
      Reason: see comment by roflz in this thread at Date: 2012-12-24 17:30:21 PST
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  49. Ticket change [e3f4c39693] (rid 87880) by nijtmans on 2013-01-17 20:47:19:

    1. icomment:
      Both tclWinPort.h and tclUnixPort.h should be before tcl.h, so if e.g.<sys/stat.h>
      contains the following fragment:
          ==== <sys/stat.h> ====
          #define stat stat64
          ==== end fragment ====
      then tcl.h will pick it up on the Tcl_StatBuf definition.
      
      Is HAVE_STRUCT_STAT64 defined on OSX? If not, that could be the bug.
      
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  50. Ticket change [ef1140709a] (rid 108928) by twylite on 2013-01-17 20:50:05:

    1. icomment:
      dkf: Yes, there is (a reason why tclWinPort.h is before tcl.h in tclPort.h).  It's to make sure that _USE_32BIT_TIME_T is defined before you include tcl.h, so that the tcl.h handling of statbuf gives the correct definition:
      
      #if defined(__WIN32__)
      #   ifdef __BORLANDC__
      typedef struct stati64 Tcl_StatBuf;
      #   elif defined(_WIN64)
      typedef struct __stat64 Tcl_StatBuf;
      #   elif (defined(_MSC_VER) && (_MSC_VER < 1400)) || defined(_USE_32BIT_TIME_T)
      typedef struct _stati64Tcl_StatBuf;
      #   else
      typedef struct _stat32i64 Tcl_StatBuf;
      #   endif /* _MSC_VER < 1400 */
      
      
      
    2. login: "twylite"
    3. mimetype: "text/plain"
    4. username: "twylite"
  51. Ticket change [3d2ecc74bb] (rid 121044) by dkf on 2013-01-17 20:56:09:

    1. icomment:
      Hmm, and right now there's logic in tcl.h that makes sure that OSX picks up the correct stat structure. It's stuff that would belong in configure, except that OSX builds (of Leopard vintage at least) are actually multi-architecture builds. Messy.
      
      Perhaps we should somehow duplicate the logic for deciding which stat API to use so that the include order can be in one direction on all platforms.
      
      And for 8.6? NO MORE USE OF 'struct stat' IN TCL's PUBLIC API!
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  52. Ticket change [7d03994452] (rid 97173) by dkf on 2013-01-17 20:56:16:

    1. icomment:
      Hmm, and right now there's logic in tcl.h that makes sure that OSX picks up the correct stat structure. It's stuff that would belong in configure, except that OSX builds (of Leopard vintage at least) are actually multi-architecture builds. Messy.
      
      Perhaps we should somehow duplicate the logic for deciding which stat API to use so that the include order can be in one direction on all platforms.
      
      And for 9.0? NO MORE USE OF 'struct stat' IN TCL's PUBLIC API!
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  53. Ticket change [9233548b24] (rid 120736) by dkf on 2013-01-17 20:56:30:

    1. icomment:
      
      
      IP - Comment Removed: 130.88.99.220
      
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  54. Ticket change [1f8dc6fe6f] (rid 91165) by nijtmans on 2013-01-18 22:11:20:

    1. icomment:
      Donal, could you try the current "bug-3598300" branch,
      (based on core-8-5-branch) ?
      
      The logic is actually simple. In tcl.h:
      #if defined(__APPLE__)
      ...
      #   undef HAVE_STRUCT_STAT64
      #endif
      
      This #undef comes too late to be usable in tclUnixPort.h, that's the problem!
      
      This means that on __APPLE__ we simply should not
      use stat64, even though HAVE_STRUCT_STAT64 is
      defined. Better would be to change the configure
      script such that if __APPLE__ is defined that then
      HAVE_STRUCT_STAT64 is NEVER defined. But
      then TEA should be adapted as well.
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  55. Ticket change [d04bbd385f] (rid 113154) by dkf on 2013-01-18 22:22:00:

    1. icomment:
      That branch builds clean on OSX Leopard (excepting known-unrelated issues in tclLoadDyld.c which should *not* be addressed) and passes --enable-symbols=mem test run with no failures.
      
      Looks good.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  56. Ticket change [e500dde688] (rid 88051) by dkf on 2013-01-18 22:25:19:

    1. icomment:
      [For reference: the LoadDyld warnings relate to how we do load-from-VFS on OSX; the API that we use to do it has been deprecated by Apple in favor of an API which can't support the functionality. So we put up with the warnings. I've got a "fix" on one of the novem branches that silences the warnings, but it's truly not worth us trying to backport.]
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  57. Ticket change [3ab2000fbd] (rid 112602) by nijtmans on 2013-01-20 01:56:11:

    1. icomment:
      Donal, could you try branch "novem-bug-3598300" as well? I suspect that on
      OSX the only reason for not defining HAVE_STRUCT_STAT64 was because
      of binary compatibility with older OSX releases, which didn't have stat64 yet.
      If so, then for "novem" we can break binary compatibility and enable
      HAVE_STRUCT_STAT64 (or - better- introduce HAVE_NO_STRUCT_STAT64)
      
      For Win32, the same could be done, but that would mean
      that VC6 must be phased out: it doesn't have a stat64-like
      structure which has 64-bit file sizes, so that cannot be done
      without a TIP (which I would approve, BTW)...
      
      Donal, does this approach work on your OSX machines?
      Your opinion please, before merging this to "novem"
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  58. Ticket change [c8a7c2098b] (rid 122142) by dkf on 2013-01-20 05:36:56:

    1. icomment:
      OSX Leopard definitely has stat64 as well as stat. The stat64 version is interesting because it knows the creation instant for the file as well as the traditional three POSIX times.
      
      I have no idea what later versions of OSX support. We don't support earlier versions of OSX for sure (especially with Tk).
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  59. Ticket change [2d1a5b9d32] (rid 259695) by serhiy.storchaka on 2026-10-21 10:03:35:

    1. icomment:
      Fixed in 8.5.14 and 8.6.1 by [992ef8a601] and [590472b443]: tclPort.h now includes tclUnixPort.h (and so <tt>&lt;sys/stat.h&gt;</tt>) before tcl.h, also on macOS. In Tcl 9, tcl.h always uses <tt>struct stat</tt> on Unix.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"