From cb24eb8345c222357d2fec6542a6564915e1d8d9 Mon Sep 17 00:00:00 2001 From: Narayanan Iyer Date: Fri, 28 Jan 2022 11:45:53 -0500 Subject: [PATCH] [#840] Fix SIG-11 from $ZATRANSFORM when first argument is an undefined variable Background ---------- * The below test case fails with YottaDB r1.32 but does not with r1.30. **Release build** ```m YDB>write $zatransform(x,0) %YDB-E-ZATRANSERR, The input string is too long to convert YDB>write $zatransform(x,0,2) %YDB-F-KILLBYSIGSINFO1, YottaDB process 91088 has been killed by a signal 11 at address 0x00007F4598A9DB8A (vaddr 0x0000000000000000) %YDB-F-SIGMAPERR, Signal was caused by an address not mapped to an object ``` **Debug build** ```m YDB>write $zatransform(x,0) %YDB-F-ASSERT, Assert failed in sr_port/op_fnzatransform.c line 75 for expression (FALSE) YDB>write $zatransform(x,0,2) %YDB-F-KILLBYSIGSINFO1, YottaDB process 91223 has been killed by a signal 11 at address 0x00007F2FC1DD9FB3 (vaddr 0x0000000000000000) %YDB-F-SIGMAPERR, Signal was caused by an address not mapped to an object ``` * This is a regression in #724 (0b63ce10 as part of !959) that was noticed during fuzz testing (#828). Issue ----- * If the input argument is undefined, the code in `op_fnzatransformm.c` used to return right away because it had a check of `if (0 == msrc->str.len)` at function entry. This check was modified as part of 0b63ce10 to additionally check for `MV_IS_STRING(msrc)`. This meant that undefined mvals will no longer return right away like before and that means they would go further down in the code and result in assert failures and/or SIG-11s like shown above. Fix --- * A `MV_FORCE_DEFINED(msrc)` call is now added at function entry. And that will take care of issuing the appropriate `LVUNDEF` error before proceeding further down in the code. --- sr_port/op_fnzatransform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sr_port/op_fnzatransform.c b/sr_port/op_fnzatransform.c index 6a25f9102..1bd9a0c7d 100644 --- a/sr_port/op_fnzatransform.c +++ b/sr_port/op_fnzatransform.c @@ -3,7 +3,7 @@ * Copyright (c) 2012-2019 Fidelity National Information * * Services, Inc. and/or its subsidiaries. All rights reserved. * * * - * Copyright (c) 2020-2021 YottaDB LLC and/or its subsidiaries. * + * Copyright (c) 2020-2022 YottaDB LLC and/or its subsidiaries. * * All rights reserved. * * * * This source code contains the intellectual property * @@ -128,7 +128,7 @@ void op_fnzatransform(mval *msrc, int col, int reverse, int forceStr, mval *dst) rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_COLLATIONUNDEF, 1, col); } else csp = NULL; /* Do not issue COLLATIONUNDEF for 0 collation */ - + MV_FORCE_DEFINED(msrc); /* issue a LVUNDEF error if undefined */ if (MV_IS_STRING(msrc) && (0 == msrc->str.len)) { /* Null string, return it back */ *dst = *msrc;