forked from lix-project/lix
derivations.cc: Use larger buffer in printString
If we want to be careful about hitting the stack protector page, we should use `-fstack-check` instead. Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This commit is contained in:
parent
dec7748119
commit
0407436b0f
|
@ -273,15 +273,7 @@ Derivation parseDerivation(const Store & store, std::string && s, std::string_vi
|
||||||
|
|
||||||
static void printString(string & res, std::string_view s)
|
static void printString(string & res, std::string_view s)
|
||||||
{
|
{
|
||||||
// Large stack allocations can skip past the stack protection page.
|
boost::container::small_vector<char, 64 * 1024> buffer;
|
||||||
const size_t stack_protection_size = 4096;
|
|
||||||
// We reduce the max stack allocated buffer by an extra amount to increase
|
|
||||||
// the chance of hitting it, even when `fun`'s first access is some distance
|
|
||||||
// into its *further* stack frame, particularly if the call was inlined and
|
|
||||||
// therefore not writing a frame pointer.
|
|
||||||
const size_t play = 64 * sizeof(char *); // 512B on 64b archs
|
|
||||||
|
|
||||||
boost::container::small_vector<char, stack_protection_size - play> buffer;
|
|
||||||
buffer.reserve(s.size() * 2 + 2);
|
buffer.reserve(s.size() * 2 + 2);
|
||||||
char * buf = buffer.data();
|
char * buf = buffer.data();
|
||||||
char * p = buf;
|
char * p = buf;
|
||||||
|
|
Loading…
Reference in a new issue