Skip to content

Commit

Permalink
[#840] Fix SIG-11 from $ZATRANSFORM when first argument is an undefin…
Browse files Browse the repository at this point in the history
…ed 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 (0b63ce1 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 0b63ce1 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.
  • Loading branch information
nars1 committed Jan 28, 2022
1 parent 10f6c72 commit cb24eb8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sr_port/op_fnzatransform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit cb24eb8

Please sign in to comment.