After the Rust toolchain got updated from 1.89.0 to 1.94.1 on Haiku OS, I noticed that my project now fails to build with error:
fatal runtime error: out of TLS keys, aborting
out of TLS keys, aborting (screenshot)
I suppose here "TLS" refers to thread-local storage rather than transport layer security 🤔
So, it would seem that the new version of rustc attempts to use more TLS slots (keys) than the operating system can provide.
From what I understand, the maximum number of TLS (thread-local storage) keys is equal to PTHREAD_KEYS_MAX, i.e., the "Maximum number of data keys that can be created by a process". It appears that this constant is platform-specific, but the POSIX standard defines the "Minimum Acceptable Value" as another constant called _POSIX_THREAD_KEYS_MAX – which is defined as 128.
See here:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
So, this means that rustc probably should be very conservative with the number of TLS keys that it uses, because one must not assume that more than 128 TLS keys are available on any operating system. Nonetheless, it appears that Rust 1.94.1 violates the limit, whereas older Rust versions, such as 1.89.0, have been working flawlessly 😕
To make it clear, the exactly same code used to compile just fine with Rust 1.89.0 on Haiku OS. Also, my code does not even use thread_local! at all! So, I think, this must be a problem with the excessive use of thread_local! in rustc itself, not in my own code. Furthermore, the problem only started after Haiku OS updated their Rust toolchain from 1.89.0 to 1.94.1, so the "problematic" change must be anywhere in between these versions. I cannot say which version exactly broke the build, since rustup does not support Haiku OS yet, so I can only use the Rust version that Haiko OS itself provides (via pkgman).
Best regards.
Might be related:
#147590
After the Rust toolchain got updated from 1.89.0 to 1.94.1 on Haiku OS, I noticed that my project now fails to build with error:
out of TLS keys, aborting (screenshot)
I suppose here "TLS" refers to thread-local storage rather than transport layer security 🤔
So, it would seem that the new version of
rustcattempts to use more TLS slots (keys) than the operating system can provide.From what I understand, the maximum number of TLS (thread-local storage) keys is equal to
PTHREAD_KEYS_MAX, i.e., the "Maximum number of data keys that can be created by a process". It appears that this constant is platform-specific, but the POSIX standard defines the "Minimum Acceptable Value" as another constant called_POSIX_THREAD_KEYS_MAX– which is defined as 128.See here:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
So, this means that
rustcprobably should be very conservative with the number of TLS keys that it uses, because one must not assume that more than128TLS keys are available on any operating system. Nonetheless, it appears that Rust 1.94.1 violates the limit, whereas older Rust versions, such as 1.89.0, have been working flawlessly 😕To make it clear, the exactly same code used to compile just fine with Rust 1.89.0 on Haiku OS. Also, my code does not even use
thread_local!at all! So, I think, this must be a problem with the excessive use ofthread_local!inrustcitself, not in my own code. Furthermore, the problem only started after Haiku OS updated their Rust toolchain from 1.89.0 to 1.94.1, so the "problematic" change must be anywhere in between these versions. I cannot say which version exactly broke the build, sincerustupdoes not support Haiku OS yet, so I can only use the Rust version that Haiko OS itself provides (viapkgman).Best regards.
Might be related:
#147590