8 ms·
The perils of transition to 64-bit time_t
- Netch 2y agoAll this suggests the insane Windows time (64 bits of 100ns periods since 01.01.1601 00:00 GMT as it would have been Gregorian) sometimes has it small advantages - both an excellent discretion and will work even the whole galaxy will be conquerred... ;))
- kccqzy 2y agoMy biggest takeaway (and perhaps besides-the-point) is this: > Musl has already switched to that, glibc supports it as an option. A number of other distributions such as Debian have taken the leap and switched. Unfortunately, source-based distributions such as Gentoo don’t have it that easy. While I applaud their efforts I just think as a user I want to be over and done with this problem by switching to a non source-based distribution such as Debian.
- wtallis 2y agoIt sounds like the difficulty for source-based distributions comes from trying to do an in-place upgrade that makes incompatible changes to the ABI. So changing to an entirely different distribution would be at least as disruptive (though possibly less time consuming) as doing a clean install of Gentoo using a new ABI.
- akira2501 2y agoStarting a few years ago I partition all my drives with two root partitions. Once is used and the other is blank. For precisely this reason. Sometimes it's easier to just roll out a brand new stage3 onto the unused partition, build an entirely new root, and then just move over to that once it's finished. The bonus is you can build your new system from your old system using just chroot. Very convenient.
- jasomill 2y agoSeveral OSes I use on a daily basis (FreeBSD, Fedora CoreOS, and Fedora Kinoite) adopt related strategies as part of their regular (binary) update processes: https://wiki.freebsd.org/BootEnvironments https://wiki.freebsd.org/BootEnvironments https://coreos.github.io/rpm-ostree/ https://coreos.github.io/rpm-ostree/
- naitgacem 2y agoAndroid adopted an approach in a similar spirit. https://source.android.com/docs/core/ota/ab https://source.android.com/docs/core/ota/ab
- ordu 2y agoThere is an easy way to deal with this in Gentoo. Boot from usb or something, run mkfs.ext4 (or .whatever fs you use) on your / and /usr partitions, mount them, unpack stage3 on them, chroot into them and run `emerge $all-my-packages-that-where-installed-before-mkfs`. You can install new copy of Gentoo instead of upgrading it incrementally.
- robin_reala 2y ago“easy”
- ordu 2y agoIt is easy. It is just a tl;dr version of "how to install gentoo". :)
- lnxg33k1 2y agoI hope I will get a day where I have the will to recompile everything in the next 14 years, I think I had the same install for the past 10 or so on the gentoo desktop. The only think I reinstalled recently has been the laptop to switch from arch to sid
- account42 2y agoWow you bother with a separate install (and different distro for you laptop). When I got a new laptop last year I just copied over my desktop install and adjusted things as needed. Setting everything up from scratch is too much work.
- seanhunter 2y agoThis doesn't take into account any binaries that are in users home directories or locally installed. So for example anything compiled as part of a python virtualenv for a developer or anything they built in rust using cargo etc. Yes there are ways to deal with those things, but it doesn't change the fact that this transition is a big deal.
- 2y ago
- viraptor 2y ago> by switching to a non source-based distribution such as Debian. The distinction has more nuance. Source based distros like nixos don't have the same issue. The problem is more in how Gentoo builds/installs the packages than in building from source. Also with third party closed source software, you're still going to have issues, even on binary systems. Actually you could even have issues with the first party packages if they're installed in separate independent steps.
- n_plus_1_acc 2y agoI'm no expert on C, but I was under the impression that type aliases like off_t are introduced to have the possibility to change then later. This clearly doesn't work. Am I wrong?
- smueller1234 2y agoThey make it easier, but just at a source code level. They're not a real (and certainly not full) abstraction. An example that'll be making it obvious: if you replace the underlying type with a floating point type, the semantics would change dramatically, fully visible to the user code. With larger types that otherwise have similar semantics, you can still have breakage. A straightforward one would be padding in structs. Another one is that a lot of use cases convert pointers to integers and back, so if you change the underlying representation, that's guaranteed to break. Whether that's a good or not is another question, but it's certainly not uncommon. (Edit: sibling comments make the same point much more succinctly: ABI compatibility!)
- SkiFire13 2y agoYeah, the problem in general with type aliases is that they're just that, aliases, not proper types. This means that they leak all the details of the underlying type, and don't work for proper encapsulation, which is what's needed for being able to change what should be implementation details.
- tsimionescu 2y agoThe problem here would be exactly the same regardless of what form this type took. The issue is fundamental to any low level language: the size of a type is a part of its public API (well, ABI), by definition. This is true in C++ with private fields as well, for example: if you add a private field to a class, or change the type of a private field with one of a different size, all code using that class has to be re-built. The only way to abstract this is to use types strictly through pointers, the way Java does.
- ordu 2y agoIt kinda work, but not in a source based distro. If you can atomically rebuild @world with changed definition of off_t, then there will be no problem. But source based distro doesn't rebuild @world atomically. It rebuild one package at time, so there would be inconveniences like libc.so has 64-bit off_t, while gcc was build for 32-bit off_t, so gcc stops working. Or maybe bash, coreutils, make, binutils or any other package that is needed for rebuilding @world. At this point you are stuck. So such upgrade needs care.
- BoingBoomTschak 2y agoA very thoughtful way of handling a problem much trickier than the earlier /usr merge. Had thought about 2 but not 1 and 3. I also had kinda forgotten that 2038 thing, time sure is flying! I must say, mgorny's posts are always a treat for those who like to peer under the hood! (The fact that Gentoo has remained my happy place for years doesn't influence this position, though there's probably some correlation)
- fred_is_fred 2y agoBesides epoch time and the LFS support mentioned, are there any other 32-bit bombs waiting for Linux systems like this?
- fph 2y agoIPv4, technically, is another 32-bit bomb, but that's not Linux-specific.
- samatman 2y agoI wouldn't call this a bomb at all. Bombs are events, not processes. Resource contention for IPv4 has been around for a long time, with a number of workarounds and the ultimate out of supporting IPv6. There has been, to date, no moment of crisis, nor do I expect one in the future. It will just get steadily more annoying/expensive to use IPv4 and IPv6 will relieve that pressure incrementally. We're at least two decades into that process already.
- deleted 2y ago[deleted]
- poincaredisk 2y agoTwo decades in, and IPv6 is still the more annoying option. I wish they were less ambitious and just increased address sizes when designing ipv6.
- icedchai 2y agoIf more people bothered to configure IPv6 instead of complaining about it, V4 would be a thing of the past already.
- o11c 2y agoA lot of people don't have a choice. Just last(?) year I finally switched to an ISP whose equipment supports IPv6. But I still can't actually use it since my wifi router's support for IPv6 somehow fails to talk to the ISP equipment. Hm, there's a firmware upgrade ... (installs it) well, re-trying all those options again, it looks like one of them lets it finally work now. The others (including the default) still fail with arcane errors though!
- loeg 2y agoThe C standard does not require time_t to be signed (nor does POSIX). Just changing the 32-bit type to unsigned would (in some senses) extend the lifetime of the type out to 2106. You could at least avoid some classes of ABI breakage in this way. (On the other hand, Glibc has explicitly documented that its time_t is always signed. So they do not have this option.)
- account42 2y agoAh yes, let's introduce subtle bugs or code that calculates the difference between two time_t's where the result can be negative. If something is effectively always signed you can assume that things depend on it being signed even if the standard doesn't guarantee it. If you are building a Linux distribution you can't just handwave such code away as "technically it was already broken on this theoretical POSIX compliant platform that no one uses".
- deleted 2y ago[deleted]
- School-Cotton 2y agoYou would then lose the ability to represent times before Jan. 1st, 1970. Which is not just a theoretical concern; those times appear e.g. in databases with people's date of birth.
- nobluster 2y agoAnd a signed 32 bit time_t with an epoch of 1970 cannot represent dates before 1902. Using time_t to store legacy dates is not advisable - even if you ignore all the issues with time zones and changing local laws pertaining to offsets from UTC and daylight saving time.
- pwg 2y agoWhile true, that limitation has always existed, so everyone has already implemented whatever was necessary to represent dates earlier than that. Changing 32-bit time_t to unsigned suddenly makes all dates from 1902 to Jan 1 1970 which were stored using time_t (even if it was non-advisable, it still will have occurred) appear to teleport into the future beyond 2038.
- codys 2y agoThere are a few options for Gentoo not discussed in the post, possibly because for Gentoo they would be a larger amount of work due to the design of their system: 1. Allow building against packages without installing them. The core issue here is that Gentoo package build and install happen as a single step: one can't "build a bunch of things that depend on one another" and then "atomically install all the build items into place". This means that Gentoo can easily be partially broken when one is doing updates when an ABI change occurs (modulo so versioning, see next option). This issue with 64-bit time_t is an example of an ABI change that folks are very aware of and is very widespread. It's also an example of something that causes an ABI change that isn't handled by the normal `.so` versioning scheme (see next option). 2. Extend the normal `.so` versioning to capture changes to the ABI of packages caused by packages they depend on. Normally, every `.so` (shared object/library) embeds a version number within it, and is also installed with that version number in the file name (`libfoo.so.1.0.0`, for example, would be the real `.so` file, and would have a symlink from `libfoo.so` to tell the linker which `.so` to use). This shared object version is normally managed by the package itself internally (iow: every package decides on their ABI version number to enable them to track their own internal ABI breakages). This allows Gentoo to upgrade without breaking everything while an update is going on as long as every package manages their `.so` version perfectly correctly (not a given, but does help in many cases). There is a process in Gentoo to remove old `.so.x.y.z` files that are no longer used after an install completes. What we'd need to do to support 64-bit time_t is add another component to this version that can be controlled by the inherited ABI of dependencies of each `.so`. This is very similar in result to the "use a different libdir" option from the post, but while it has the potential to set things up to enable the same kinds of ABI changes to be made in the future, it's likely that fixing this would be more invasive than using a different libdir.
- account42 2y agoGentoo already does retain old libraries until all dependends are updated so encoding the abi change in places where ABI changes are supposed to be encoded (architecture and SONAME) would solve this problem.
- akira2501 2y ago> Allow building against packages without installing them. A partial staged update system would work the best. I should be able to schedule the build of several new packages, have them built into a sandbox, and have new compilations use the sandbox first and then fallback to the system through a union, and then once everything is build finally package up all the pieces and then move them out of the sandbox and into the system at large. You could make all gentoo updates transactional that way which would be a huge boon in many other ways.
- nobluster 2y agoFor a large legacy 32 bit unix system dealing with forward dates I replaced all the signed 32 bit time_t libc functions with unsigned 32 bit time_t equivalents. This bought the system another 68 years beyond 2038 - long after I'll be gone. The downside is that it cannot represent dates before the unix epoch, 1970, but as it was a scheduling system it wasn't an issue. If legacy dates were a concern one could shift the epoch by a couple of decades, or even reduce the time granularity from 1 second to 2 seconds. Each alternative has subtle problems of their own. It depends on the use case.
- suprjami 2y agoIf you can change the whole system from signed to unsigned, why not change to 64-bit?
- deleted 2y ago[deleted]
- Dylan16807 2y agoThe main problem here is gradual upgrades. Signed and unsigned code act exactly the same on dates before 2038, so you can upgrade piece by piece at your leisure. The suggestions for messing with epoch or the timescale wouldn't work nearly as well, for those just switch to 64 bit.
- suprjami 2y agoIt sounds like the parent poster controls the whole system, so there is no gradual upgrade. If they're changing signed time to unsigned time, it seems to me they can change the size of time as well.
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- dark-star 2y agoAre there other distros where the switch to 64-bit time_t has already happened? What's the easiest way to figure out whether $distro uses 32-bit or 64-bit time_t? Is there something easier/quicker than writing a program to print `sizeof(struct stat)` and check if that's 88, 96 or 1098 bytes (as hinted in the article)?
- teddyh 2y agoLike the article says, Debian has already switched.
- jonathrg 2y agoprintf '#include <stdio.h>\n#include <time.h>\nint main() { printf("time_t is %%zu-bit\\n", sizeof(time_t)*8); }\n' | gcc -x c -o timesize - && ./timesize && rm ./timesize If you're wondering about a specific distro that you're not using right now - just look it up.
- SAI_Peregrinus 2y agoNixOS switched. And they're source-based, but with actual dependency tracking and all the (insanely complex) machinery needed to allow different programs to use different C library versions simultaneously. `printf("sizeof (time_t) = %zu, %zu bits", sizeof (time_t), sizeof (time_t) * CHAR_BIT);` gives you the size in bytes and in bits. Needs time.h, stddef.h, and stdio.h.
- grantla 2y ago> A number of other distributions such as Debian have taken the leap and switched. Unfortunately, source-based distributions such as Gentoo don’t have it that easy. For Debian it was extremely painful. A few people probably burned out. Lots of people pointed to source-based distributions and said "they will have it very easy".
- Denvercoder9 2y ago> For Debian it was extremely painful. Do you have any references that elaborate on that? From an outsider perspective, the time64 transition in Debian seemed to have been relatively uncontroversial and smooth. Way better than e.g. the /usr-merge.
- jlarocco 2y agohttps://lwn.net/Articles/812767/ https://lwn.net/Articles/812767/ https://wiki.debian.org/ReleaseGoals/64bit-time https://wiki.debian.org/ReleaseGoals/64bit-time I'm continually impressed by Debian. My Debian systems are pretty boring, so maybe it's to be expected, but as an end-user neither the /usr merge or time64 transition broke anything for me, and I'm using Testing.
- ajsnigrutin 2y ago> For Debian it was extremely painful. A few people probably burned out. Lots of people pointed to source-based distributions and said "they will have it very easy". 'easy' in a way "just tell the user to rebuild everything in one go"? :)
- cbmuser 2y ago> For Debian it was extremely painful. I did the transition for m68k, powerpc and sh4 and partially for hppa with the help of some other Debian Developers here and there and I'm still alive ;-).
- cryptonector 2y agoThe simplest thing to do is to make any 32-bit `time_t`s be unsigned. That buys another 68 years to get the transition done. Not that that's exactly easy, but it's easier than switching to 64-bit time_t.
- rini17 2y agoYou believe it will get somehow easier in 60 years?
- cryptonector 2y agoYes! For one, none of us will be the ones dealing with it, but more seriously, by then 32-bit Unix/Linux ABIs will be gone.
- jeffbee 2y agoAre we still keeping shared libraries? They are a complex solution to a problem that arguably stopped existing 20 years ago. Might be time to rethink the entire scheme.
- account42 2y agoHave you looked at the size of some of the shared libraries on your system. E.g. check Qt. You don't want to statically link that into every tiny utility program.
- filmor 2y agoOn Gentoo, definitely. I really don't want to rebuild my whole system whenever some foundational library fixes a bug. It already annoys me quite a bit that I need to set up sccache to get half-way reasonable compile times out of Rust projects (and I'm saying that as someone who enjoys gradually replacing significant portions of the userspace with Rust tools).
- AshamedCaptain 2y agoThis by itself is half the reason I think Nix's approach is a step backwards.
- otabdeveloper4 2y agoThe Docker image layers you so dearly love are an implementation of shared libraries, except done in a broken way that's a thousand times less performant and more insecure.
- wpollock 2y agoI'm probably naive, but I see another way forward. If all the t64 binaries are static linked, they have no danger of mixing abis. After 2038, all the t32 code is broken anyway so there's no additional risk for going back to dynamic linking then. I feel if this was a solution the author would have mentioned it but I'm willing to look foolish to hear what others will say.
- layer8 2y agoStatic linking is probably impractical for applying security updates, as often you’d have to recompile/relink basically the whole system. In some cases it could also significantly increase memory usage.
- GeorgeTirebiter 2y agowith fast networks, huge disks, fast processors --- it seems wasteful to me to even consider shared libraries. Shared libraries is a technology that was useful when we were memory starved. We are no longer memory starved. So you replace the static binary? Big deal, size is not an issue (for 99% of the cases) given what we have today. Recall, too, that the "link" step of those .o files is actually a "link / edit" step, where routines in the libraries not used are not linked.
- account42 2y agoHave you looked at the size of your average GUI toolkit lately. Dynamic linking is still very much needed. Besides I like my faster processor and larger disks/ram actually making things faster for me and letting me do more instead of being wasted on developer lazyness.
- layer8 2y agoIt’s much more straightforward to ensure consistency with shared libraries, and not having to rebuild stuff. Wasting disk space, RAM, network bandwidth and processing time is what seems wasteful to me.
- gotoeleven 2y ago
- layer8 2y ago> The second part is much harder. Obviously, as soon as we’re past the 2038 cutoff date, all 32-bit programs — using system libraries or not — will simply start failing in horrible ways. One possibility is to work with faketime to control the system clock. Another is to run a whole VM that’s moved back in time. Yet another is to freeze the time for those programs at the last 32-bit POSIX second. They would just appear to execute incredibly fast :). Of course some will still break, and it’s obviously not suitable for many use cases (but neither is running in the past), but some might be just fine.
- account42 2y agoI imagine more program would break if time stops advancing at a reasonable pace than those that break by getting weird times due to wraparound. Delays and animations are much more common than caring about absolute timestamps.
- ndesaulniers 2y agoI think we should start putting details of the ABI in ELF (not the compiler flags as a string). Wait.. Who owns the ELF spec?? Then the linker and loader could error if two incompatible objects with different ABIs were attempted to be linked together. For instance, I suspect you could have fields to denote the size of certain types. I guess DWARF has that... But DWARF is optional and sucks to parse.
- SubjectToChange 2y agoI think we should start putting details of the ABI in ELF That basically implies name mangling in some form or another, i.e. good luck trying to convince C programmers of such a thing.
- ndesaulniers 2y agoI didn't find name managing to be the problem here. C symbols are mangled in mach-o.
- ddoolin 2y agoWhy was it 32 bits to begin with? Wasn't it known that 2038 would be the cutoff?
- NegativeLatency 2y agoUltimately probably hardware? I suspect it’s also been like this for a long time.
- account42 2y agoYeah when you RAM sizes are measured in KB or low MB and your processor has not support for 64-bit integers you tend to think about works now instead of what will still work in 60 years.
- jdndhdhd 2y agoWhy is it 64 bit now? Isn't it know that 292277026596 would be the cutoff?
- account42 2y agoThe sun will have died by then so we will have bigger problems. Slightly different timespan than 60 years where some people will be able to experience both the start and the end.
- int_19h 2y agoIt was not exactly a big concern when this was designed in early 70s, especially when you consider that Unix itself was kind of a hack at the time.
- wongarsu 2y agoIt has been that way since Unix V4 which released in 1973. Back then moving to something that breaks after 65 years was a massive upgrade over the old format that wrapped after two and a half years. And at least from the standpoint of Unix engineers 32 bits was more than enough: Nobody is using Unix V4 in production in 2024, never mind 2038. Why it made it into Posix and wasn't updated is a different question that's a bit more difficult to answer
- eschaton 2y agoThe way this was handled on Mac OS X for `off_t` and `ino_t` might provide some insight: The existing calls and structures using the types retained their behavior, new calls and types with `64` suffixes were added, and you could use a preprocessor macro to choose which calls and structs were actually referenced—but they were hardly ever used directly. Instead, the OS and its SDK are versioned, and at build time you can also specify the earliest OS version your compiled binary needes to run on. So using this, the headers ensured the proper macros were selected automatically. (This is the same mechanism by which new/deprecated-in-some-version annotations would get set to enable weak linking for a symbol or to generate warnings for it respectively.) And it was all handled initially via the preprocessor, though now the compilers have a much more sophisticated understanding of what Apple refers to as “API availability.” So it should be feasible to use the same mechanisms on any other platform too.
- db48x 2y agoLol, that only works if you can force everyone on the platform to go along with it. It is a nice solution, but it requires you to control the c library. Gentoo doesn’t control what libc does; that’s either GNU libc or MUSL or some other thing that the user wants to use.
- dmitrygr 2y ago> requires you to control the c library Which is why basically every other same operating system does that. BSDs, macOS, WinNT. Having the stable boundary be the kernel system call interface is fucking insane. And somehow the Linux userspace people keep failing to learn this lesson, no matter how many times they get clobbered in the face by the consequences of not learning it.
- eschaton 2y agoAnd yet it would still work out for Linux if musl, glibc, et al just adopted `API_VERSION_MIN` and `API_VERSION_MAX` macros themselves, it doesn’t actually have to be handled entirely at the `-isysroot` level.
- 2y ago
- panzi 2y agoThe only place where this is relevant for me is running old Windows games via wine. Wonder how wine is handling this? Might as well re-map the date for 32bit wine to the late 90s/early 2000s, where my games are from. Heck, with faketime I can do that already, but don't need it yet.
- account42 2y agoWin32 doesn't use time_t internally and has had 64-bit FILETIME since Windows 95 (counting 100-nanoseconds since 1601) as well as 64-bit performance counters (ticks) which are often used by games. Similarly, SYSTEMTIME has a 16-bit unsigned year field so should be good for a while. There is also an older GetTickCount() with 32-bit times but it is less problematic since a) it counts (milliseconds) since system startup and b) it is typically used to determine the time between two points (e.g. one frame to the next) so wraparound is not as much of an issue. time_t is provided in the C-library but many Windows programs don't end up using it. The CRT also has had __time64_t for a long time now for this purpose. 16-bit Windows/DOS programs often use the FAT filetime format which can store dates until 2099. TL;DR Windows/Wine internally does not need to change anything for a long time. Of course inevitably some applications will use 32-bit time_t or other 32-bit integers to store timestamps internally and will require workarounds.
- ok123456 2y agoWhat about making time_t 64-bit across all profiles and incrementing all the profile versions by one? Gentoo users are used to breaking changes when upgrading profiles.
- mhandley 2y ago"Let’s consider a trivial example: struct { int a; time_t b; int c; }; With 32-bit time_t, the offset of c is 8. With the 64-bit type, it’s 12." Surely it's 16 not 12, as b needs to be 64-bit aligned, so padding is added between a and b? Which also kind of makes the point the author is trying to make stronger.
- AshamedCaptain 2y agoMost x86 ABIs do not mandate padding for 64-bit types, due to the lack of 64-bit loads (at the time).
- 256_ 2y agoI thought you were right, but I tested it on x86_64 GNU/Linux with this struct: struct ts { int32_t dword1; int64_t qword1; int32_t dword2; }; Writing -1 to all 3 members and printing out the individual bytes up to sizeof(struct ts), it produces this with -O0 and -O3: FF FF FF FF 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 With -Os, I get some garbage data after the last member (always those 2 byte positions, with different values every time): FF FF FF FF 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF 45 76 00 00 I feel like I'm missing something obvious here. Or maybe my system's ABI is a weird exception.
- rini17 2y agoHope Gentoo alone won't get overburdened with the development and maintenance of such hybrid toolchain, to be able to compile and run time32 processes alongside time64. When everyone else has moved on. Better do a complete reinstall from stage3.
- account42 2y agoNot just dropping old stuff immediately when its no longer hip is one of the main strengths of Gentoo.
- rini17 2y agoOne needs to draw a line when it's too painful. There's a precedent - both symlinked and unsymlinked profiles exist and migration is fragile, sometimes you have to rebuild everything anyway. There could be time32 and time64 profiles like that as well, with former eventually deprecated.
- malkia 2y agoMicrosoft's famous (infamous?) "A" / "W" functions and macros controlling them -... but it works and one can link two different versions no problem. Wonder if that was possible here?
- kazinator 2y agoAll those arguments apply to off_t also. If a small-file executable with 32 bit off_t uses a large-file library with 64 bit off_t, there is no protection. Only glibc has the multiply implemented functions, selected by header file macrology.
- account42 2y agoYes but file offsets are a lot less common in library interfaces. And failures require files that are actually that large (well, inode numbers are also affected) so the impact is a lot more limited and gradual - everything will still work with small files whereas time_t will fail from just the passage of time.
- shmerl 2y agoLFS should have become mandatory.
- darkhelmet 2y agoEvery time I see people struggling with this, I am so incredibly glad that I forced the issue for FreeBSD when I did the initial amd64 port. I got to set the fundamental types in the ABI and decided to look forward rather than backward. The amd64 architecture did have some interesting features that made this much easier than it might have been for other cpu architectures. One of which was the automatic cast of 32 bit function arguments to 64 bit during the function call. In most cases, if you passed a 32 bit time integer to a function expecting a 64 bit time_t, it Just Worked(TM) during the platform bringup. This meant that a lot of the work on the loose ends could be deferred. We did have some other 64 bit platforms at the time, but they did not have a 64 bit time_t. FreeBSD/amd64 was the first in its family, back in 2003/2004/2005. If I remember correctly, sparc64 migrated to 64 bit time_t. The biggest problem that I faced was that (at the time) tzcode was not 64 bit safe. It used some algorithms in its 'struct tm' normalization that ended up in some rather degenerate conditions, eg: iteratively trying to calculate the day/month/year for time_t(2^62). IIRC, I cheated rather than change tzcode significantly, and made it simply fail for years before approx 1900, or after approx 10000. I am pretty sure that this has been fixed upstream in tzcode long ago. We did have a few years of whackamole with occasional 32/64 time mixups where 3rd party code would be sloppy in its handling of int/long/time_t when handling data structures in files or on the network. But for the most part, it was a non-issue for us. Being able to have 64 bit time_t on day 1 avoided most of the problem. Doing it from the start was easy. Linux missed a huge opportunity to do the same when it began its amd64/x86_64 port. Aside: I did not finish 64 bit ino_t at the time. 32 bit inode numbers were heavily exposed in many, many places. Even on-disk file systems, directory structures in UFS, and many, many more. There was no practical way to handle it for FreeBSD/amd64 from the start while it was a low-tier platform without being massively disruptive to the other tier-1 architectures. I did the work - twice - but somebody else eventually finished it - and fixed a number of other unfortunately short constants as well (eg: mountpoint path lengths etc).
- Netch 2y agoFreeBSD was also more radical in dealing with off_t which became 64 bits since 2.0. Linux still has rudiments of old size in its 32-bit versions. > One of which was the automatic cast of 32 bit function arguments to 64 bit during the function call. AFAIU this works only for unsigned arguments (as loading to %edi clears upper part of %rdi). SysV ABI spec for x86-64 says nothing about extending all values in registers or stack to full 64-bit value, and comment on boolean (only LS byte contains something significant) suggests this is a common rule.
- seanhunter 2y agoIn the original BSD man pages, the "Bugs" section for "tunefs" had the famous joke "You can tune a file system, but you can't tune a fish." but according to "Expert C Programming"[1], the source code for this manpage had a comment next to the joke saying > Take this out and a UNIX Demon will dog your steps from now > until the time_t's wrap around. Obviously back in the 70s when that was written 2038 seemed unimaginably far in the future. [1] https://progforperf.github.io/Expert_C_Programming.pdf https://progforperf.github.io/Expert_C_Programming.pdf
- M95D 2y agoI belive this problem is irrelevant. 32bit platforms are mostly unsupported, with Gentoo doing eforts to keep them working and mostly failing. Until 2038, 32bit systems will be as rare as an i286 today.
- account42 2y ago32-bit Wine will remain relevant for a long time.
- 2ndbigbang 2y agoThis is not the case for embedded systems where 32-bit ARM is still used.
- M95D 2y agoCan you give some examples of embedded systems that run Gentoo?
- somat 2y agoJust pull the bandaid off, it will hurt a little, but not as bad as this endless agonizing about the problem. For what it's worth, on openbsd this problem is fixed, all architectures, even the 32bit ones, have a 64bit time_t. http://www.openbsd.org/55.html http://www.openbsd.org/55.html
- wallstprog 2y agoBriefly mentioned elsewhere in the comments, but C++11 had a similar issue around the transition from a copy-on-write (COW) to a small-string-optimization (SSO) implementation for std::string. If any type is more ubiquitous than std::string, I don't know what it could be, but the transition was reasonably painless, at least in my shop. See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_a... for more info.