Impala Public Jenkins has submitted this change and it was merged. Change subject: IMPALA-5912: fix crash in trunc(..., "WW") in release build ......................................................................
IMPALA-5912: fix crash in trunc(..., "WW") in release build The bug is with the pattern below: const date& d = TruncMonth(orig_date).date(); The problem is that 'd' is a reference into the temporary returned from TruncMonth. But the temporary is only guaranteed to live until the expression has been evaluated. Thus if the compiler re-uses the register or stack slot holding the temporary, 'd' may end up pointing to a bogus value, causing a crash or incorrect results. The fix is to simply create a local date value with the required date, which avoids use of references to expression temporary and makes the logic more obviously correct. Also remove other uses of references to temporary that were correct but unnecessary given that the function returned a value and C++11 return value optimisation should kick in. Testing: Ran expr-test to completion with a release build. Before this fix it reliably crashed for me. Change-Id: Ic5017518188f5025daa5040ca1943581a0675726 Reviewed-on: http://gerrit.cloudera.org:8080/8015 Reviewed-by: Thomas Tauber-Marshall <[email protected]> Reviewed-by: Dan Hecht <[email protected]> Tested-by: Impala Public Jenkins --- M be/src/exprs/udf-builtins.cc 1 file changed, 6 insertions(+), 6 deletions(-) Approvals: Impala Public Jenkins: Verified Thomas Tauber-Marshall: Looks good to me, but someone else must approve Dan Hecht: Looks good to me, approved -- To view, visit http://gerrit.cloudera.org:8080/8015 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic5017518188f5025daa5040ca1943581a0675726 Gerrit-PatchSet: 2 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: Tim Armstrong <[email protected]> Gerrit-Reviewer: Dan Hecht <[email protected]> Gerrit-Reviewer: Impala Public Jenkins Gerrit-Reviewer: Matthew Jacobs <[email protected]> Gerrit-Reviewer: Thomas Tauber-Marshall <[email protected]> Gerrit-Reviewer: Tim Armstrong <[email protected]>
