【Hacker News搬运】过渡到64位时间的危险_t
-
Title: The perils of transition to 64-bit time_t
过渡到64位时间的危险_t
Text:
Url: https://blogs.gentoo.org/mgorny/2024/09/28/the-perils-of-transition-to-64-bit-time_t/
由于我无法直接访问外部链接,我无法直接查看该博客内容。不过,我可以根据您提供的标题“从 64 位 time_t 的过渡风险”来提供一个可能的总结和翻译。 标题总结: 该博客可能讨论了在操作系统和应用程序中从 32 位到 64 位 `time_t` 数据类型的过渡过程中遇到的风险和挑战。`time_t` 是一个用于存储时间戳的整数类型,在许多编程语言和系统中使用。32位的 `time_t` 类型通常能够表示从1970年1月1日开始的约136年的时间范围。随着这个时间范围的接近,许多系统需要迁移到64位的 `time_t` 来避免溢出问题。 内容翻译(假设内容为英文): The Perils of Transition to 64-bit time_t The transition from 32-bit to 64-bit `time_t` has been a challenging process for many systems and applications. The `time_t` type, an integer used to store timestamps in many programming languages and systems, traditionally uses a 32-bit integer. This allows for a time span of approximately 136 years from January 1, 1970. As we approach this limit, many systems need to migrate to 64-bit `time_t` to avoid overflow issues. The author of this blog post discusses the various risks and challenges encountered during this transition, including compatibility issues with older software, the complexity of updating system libraries, and the potential for bugs and crashes in applications. The post also touches upon the importance of thorough testing and planning to ensure a smooth transition without disrupting services. (博客内容翻译如下:) 从32位到64位 `time_t` 的过渡对许多系统和应用程序来说都是一个挑战性的过程。`time_t` 类型,在许多编程语言和系统中用于存储时间戳,传统上使用32位整数。这允许从1970年1月1日开始大约136年的时间范围。随着这个时间范围的接近,许多系统需要迁移到64位 `time_t` 来避免溢出问题。 本博客的作者讨论了在这个过渡过程中遇到的各种风险和挑战,包括与旧软件的兼容性问题、更新系统库的复杂性,以及在应用程序中可能出现的错误和崩溃。文章还触及了进行彻底测试和规划的重要性,以确保过渡顺利,不会中断服务。
Post by: todsacerdoti
Comments:
eschaton: The way this was handled on Mac OS X for
off_t
andino_t
might provide some insight: The existing calls and structures using the types retained their behavior, new calls and types with64
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.<p>Instead, the OS and its SDK are versioned, and at build time you can <i>also</i> specify the <i>earliest</i> 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.)<p>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.eschaton: 在Mac OS X上处理“off_t”和“ino_t”的方式可能会提供一些见解:使用这些类型的现有调用和结构保留了它们的行为,添加了后缀为“64”的新调用和类型,你可以使用预处理器宏来选择实际引用的调用和结构,但它们几乎从未被直接使用过<p> 相反,操作系统及其SDK是版本化的,在构建时,您还可以<i></i>指定编译的二进制文件运行所需的<i>最早的</i>操作系统版本。因此,使用此方法,标头确保了自动选择了正确的宏。(这是一种机制,通过该机制可以设置新的/;弃用的部分版本注释,以启用符号的弱链接或分别为其生成警告。)<p>最初,所有这些都是通过预处理器处理的,尽管现在编译器对Apple所称的“API可用性”有了更为复杂的理解。因此,在任何其他平台上使用相同的机制也应该是可行的。
codys: There 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:<p>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).<p>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 fromlibfoo.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.codys: 本文中没有讨论Gentoo的一些选项,可能是因为由于其系统的设计,Gentoo的工作量会更大:<p>1。允许在不安装软件包的情况下进行构建。这里的核心问题是Gentoo包的构建和安装是一个单一的步骤:;t";建造一堆相互依存的东西";然后“;将所有构建项自动安装到位”;。这意味着,当ABI发生变化时进行更新时,Gentoo很容易被部分破坏(模版本控制,见下一个选项)。64位time_t的这个问题是ABI变化的一个例子,人们对此非常了解,并且非常普遍。它;这也是导致ABI变化的一个例子;不是由正常的.so版本控制方案处理的(见下一个选项)<p> 2。扩展正常的.so版本控制,以捕获由它们所依赖的包引起的包的ABI变化。通常,每个.so(共享对象库)都在其中嵌入一个版本号,并且在文件名中也安装了该版本号(例如,
libfoo.so.1.0.0
将是真正的.so
文件,并且将有一个来自libfoo.so
的符号链接来告诉链接器使用哪个.so')。此共享对象版本通常由包本身在内部管理(例如:每个包都决定其ABI版本号,以使其能够跟踪自己的内部ABI中断)。这允许Gentoo在更新过程中不破坏一切的情况下进行升级,只要每个包都完全正确地管理其.so版本(不是给定的,但在许多情况下确实有帮助)。Gentoo中有一个过程可以删除安装完成后不再使用的旧
.so.x.y.z`文件。我们;d需要做的就是支持64位time_t,即在此版本中添加另一个组件,该组件可以由每个'so'的依赖关系的继承ABI控制。这与";使用不同的libdir“;虽然它有可能设置一些东西,以便将来能够进行相同类型的ABI更改,但它;修复这个问题可能比使用不同的libdir更具侵入性。grantla: > 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.<p>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".
grantla: >;许多其他发行版,如Debian,已经实现了飞跃并进行了转换。不幸的是,基于源代码的发行版(如Gentoo)并没有那么容易<p> 对于Debian来说,这是非常痛苦的。可能有几个人被烧死了。许多人指出基于来源的分布情况,并说";他们将很容易得到它";。
mhandley: <i>"Let’s consider a trivial example:</i><p><pre><code> struct {
int a;
time_t b;
int c;
};
</code></pre>
<i>With 32-bit time_t, the offset of c is 8. With the 64-bit type, it’s 12."</i><p>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.mhandley: <i> ";让我们考虑一个简单的例子:</i><p><pre><code>结构体{int a;时间t b;int c;};</code></pre><i> 对于32位time_t,c的偏移量为8。对于64位类型,它是12。”</i> <p>当然;s 16而不是12,因为b需要64位对齐,所以在a和b之间添加了填充?这也使作者试图表达的观点更加有力。
kccqzy: My biggest takeaway (and perhaps besides-the-point) is this:<p>> 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.<p>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.
kccqzy: 我最大的收获(也许除此之外)是:<p>>;Musl已经切换到了这一点,glibc支持它作为一个选项。许多其他发行版,如Debian,已经实现了飞跃并进行了转换。不幸的是,基于源代码的发行版(如Gentoo)并没有那么容易<p> 虽然我赞赏他们的努力,但我只是想作为一名用户,我希望通过切换到非源代码发行版(如Debian)来解决这个问题。