global variables and static initializers that log are not sound #368
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
Feature/S3
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lix-project/lix#368
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Brought up in https://github.com/NixOS/nix/issues/10772, see also #306 and #359 for more context.
-Wl,--whole-archiveseems to work around the specific issue at hand, but the order of static initializers is undefined in C++, and lots of things assumenix::logger != nullptrand just dereference it willy nilly. In https://github.com/NixOS/nix/issues/10772 the globalnix::evalSettingsconstructor callsgetDefaultNixPath(), which ends up callinggetStateDir(), which of course callsgetHome(), which logs a warning if$HOMEisn't owned by the current user.This is fucked. We should not be doing any IO before main in the first place, and we should probably replace the raw pointer
nix::loggerwith a smart pointer or somethingThis CL fixes the logger to not be broken during static destructors: https://gerrit.lix.systems/c/lix/+/2684
I am not sure if we can avoid those completely, but at least it is now kinda sorta sound.