Tim Armstrong has uploaded a new change for review.

  http://gerrit.cloudera.org:8080/8015

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
---
M be/src/exprs/udf-builtins.cc
1 file changed, 6 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/15/8015/1
-- 
To view, visit http://gerrit.cloudera.org:8080/8015
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5017518188f5025daa5040ca1943581a0675726
Gerrit-PatchSet: 1
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Tim Armstrong <tarmstr...@cloudera.com>

Reply via email to