On 21/09/2021 14:52, Mikhail Barashkov via GNU coreutils General Discussion wrote:
On MCST Elbrus 2000, in protected mode, memory pointers can't be reused, and yes crashes in protected mode.This patch fixes this by disabling reuse_operand_strings in this mode. diff --git a/src/yes.c b/src/yes.c index b6bd35a5e..64b40f147 100644 --- a/src/yes.c +++ b/src/yes.c @@ -99,6 +99,12 @@ main (int argc, char **argv) /* Fill the buffer with one copy of the output. If possible, reuse the operands strings; this wins when the buffer would be large. */ + #ifdef __e2k__ + if (sizeof(void*) == 16) + { // In E2K protected mode we can't reuse operands memory + reuse_operand_strings = false; + } + #endif char *buf = reuse_operand_strings ? *operands : xmalloc (bufalloc); size_t bufused = 0; operandp = operands;
This looks fine. Please be careful with the use of non breaking space in your mailer, as it results in patches that don't apply. I've attached a cleaned up patch for application. cheers, Pádraig
>From c3350799a83418f8357d18530ea560c1d00f2216 Mon Sep 17 00:00:00 2001 From: Mikhail Barashkov <[email protected]> Date: Tue, 21 Sep 2021 15:47:11 +0100 Subject: [PATCH] yes: fix E2K architecture compatibility On MCST Elbrus 2000, in protected mode, memory pointers can't be reused, and yes crashes in protected mode. * src/yes.c (main): Avoid reusing operands memory in protected mode on __e2k__ architecture. --- src/yes.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/yes.c b/src/yes.c index b6bd35a5e..461fc6be5 100644 --- a/src/yes.c +++ b/src/yes.c @@ -99,6 +99,12 @@ main (int argc, char **argv) /* Fill the buffer with one copy of the output. If possible, reuse the operands strings; this wins when the buffer would be large. */ +#ifdef __e2k__ + if (sizeof (void*) == 16) + { /* In E2K protected mode we can't reuse operands memory. */ + reuse_operand_strings = false; + } +#endif char *buf = reuse_operand_strings ? *operands : xmalloc (bufalloc); size_t bufused = 0; operandp = operands; -- 2.26.2
