[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
247/376: mkList: Scrub better
From: |
Ludovic Courtès |
Subject: |
247/376: mkList: Scrub better |
Date: |
Wed, 28 Jan 2015 22:05:22 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit 6bb4c0b712788c9cec9a1721ceb3c3a5c89c4181
Author: Eelco Dolstra <address@hidden>
Date: Thu Oct 9 13:08:53 2014 +0200
mkList: Scrub better
Clearing v.app.right was not enough, because the length field of a
list only takes 32 bits, so the most significant 32 bits of v.app.left
(a.k.a. v.thunk.env) would remain. This could cause Boehm GC to
interpret it as a valid pointer.
This change reduces maximum RSS for evaluating the ‘tested’ job in
nixos/release-small.nix from 1.33 GiB to 0.80 GiB, and runtime by
about 8%.
---
src/libexpr/eval.cc | 1 +
src/libexpr/value.hh | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 5122bd1..5b9db6e 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -455,6 +455,7 @@ Bindings * EvalState::allocBindings(Bindings::size_t
capacity)
void EvalState::mkList(Value & v, unsigned int length)
{
+ clearValue(v);
v.type = tList;
v.list.length = length;
v.list.elems = length ? (Value * *) GC_MALLOC(length * sizeof(Value *)) :
0;
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index 408b5e0..5f18f62 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -96,7 +96,7 @@ struct Value
Value to ensure that the target isn't kept alive unnecessarily. */
static inline void clearValue(Value & v)
{
- v.app.right = 0;
+ v.app.left = v.app.right = 0;
}
@@ -118,8 +118,8 @@ static inline void mkBool(Value & v, bool b)
static inline void mkNull(Value & v)
{
+ clearValue(v);
v.type = tNull;
- v.app.left = v.app.right = 0; // scrub
}
- 373/376: Pedantry, (continued)
- 373/376: Pedantry, Ludovic Courtès, 2015/01/28
- 368/376: Fix build, Ludovic Courtès, 2015/01/28
- 369/376: Bla, Ludovic Courtès, 2015/01/28
- 294/376: Clean up temp roots in a more C++ way, Ludovic Courtès, 2015/01/28
- 287/376: Don't use ADDR_LIMIT_3GB, Ludovic Courtès, 2015/01/28
- 255/376: binary download: Use $NIX_CURL_FLAGS, Ludovic Courtès, 2015/01/28
- 301/376: 'build-cache-failures' -> 'build-cache-failure' in nix.conf documentation., Ludovic Courtès, 2015/01/28
- 275/376: Revert "Revert "Revert "Temporarily disable darwin builds while hydra's darwin is borked""", Ludovic Courtès, 2015/01/28
- 302/376: Don't claim FreeBSD support, Ludovic Courtès, 2015/01/28
- 274/376: Don't pull in git when doing a nix-shell, Ludovic Courtès, 2015/01/28
- 247/376: mkList: Scrub better,
Ludovic Courtès <=
- 248/376: Improved error message when encountering unsupported file types, Ludovic Courtès, 2015/01/28
- 295/376: nix-daemon: Call exit(), not _exit(), Ludovic Courtès, 2015/01/28
- 242/376: Add primop ‘attrValues’, Ludovic Courtès, 2015/01/28
- 254/376: nix-store -q: Check for conflicting flags, Ludovic Courtès, 2015/01/28
- 265/376: Merge pull request #380 from shlevy/temp-disable-darwin, Ludovic Courtès, 2015/01/28
- 253/376: nix-channel: Add --rollback flag, Ludovic Courtès, 2015/01/28
- 289/376: Document functors, Ludovic Courtès, 2015/01/28
- 259/376: Export realiseContext in libnixexpr, Ludovic Courtès, 2015/01/28
- 284/376: SSH.pm: Print a friendlier message if connecting fails, Ludovic Courtès, 2015/01/28
- 278/376: Typo, Ludovic Courtès, 2015/01/28