Mitigate a segmentation fault when a derivation has no name attribute#5127
Mitigate a segmentation fault when a derivation has no name attribute#5127fogti wants to merge 1 commit intoNixOS:masterfrom
Conversation
|
@nixinator @happysalada could you try to test a nix with this patch applied on a derivation with a missing |
|
Thank you for this, I'll add it to the list of things to do on monday. |
|
I confirmed that it works. For anyone else, this can be tested in the following repo Thank you for the PR. |
|
@edolstra could you please review/merge this? |
|
hm, maybe I should adjust the commit message to be more accurate. original patch: commit b03b02775299fc29334cb0eba0e6c64e632f534c (HEAD -> iss5113, zseri/iss5113)
Author: zseri <[email protected]>
Date: Thu Aug 12 16:25:22 2021 +0200
Try to partially mitigate a segmentation fault in libnixexpr.so when a derivation has no name attribute
diff --git a/src/libexpr/attr-set.hh b/src/libexpr/attr-set.hh
index 1da8d91df..2550ad032 100644
--- a/src/libexpr/attr-set.hh
+++ b/src/libexpr/attr-set.hh
@@ -41,7 +41,7 @@ private:
size_t size_, capacity_;
Attr attrs[0];
- Bindings(size_t capacity) : size_(0), capacity_(capacity) { }
+ Bindings(size_t capacity) : pos(&noPos), size_(0), capacity_(capacity) { }
Bindings(const Bindings & bindings) = delete;
public: |
…no name attribute This may not fix the underlying issue that the location data is not propagated early enough.
|
Seems related to #4895. |
|
yes. |
This fixes a class of crashes and introduces ptr<T> to make the code robust against this failure mode going forward. Thanks regnat for the idea of a ref<T> without overhead! Closes NixOS#4895 Closes NixOS#4893 Closes NixOS#5127 Closes NixOS#5113
|
#5192 incorporates both and uses types to prevent it in the future. |
Fixes #5113, but does not fix the underlying issue that the location data is not propagated early enough (it might fix the segmentation fault, tho).