You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@impala.apache.org by "Dan Hecht (JIRA)" <ji...@apache.org> on 2017/05/02 18:18:04 UTC

[jira] [Resolved] (IMPALA-5252) Java UDF returning string can lead to crash under memory pressure.

     [ https://issues.apache.org/jira/browse/IMPALA-5252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Hecht resolved IMPALA-5252.
-------------------------------
       Resolution: Fixed
    Fix Version/s: Impala 2.9.0

commit 741421de09f4236d9a45c00753501d6e6abe90ca
Author: Dan Hecht <dh...@cloudera.com>
Date:   Thu Apr 27 16:03:31 2017 -0700

    IMPALA-5252: Fix crash in HiveUdfCall::GetStringVal() when mem_limit exceeded

    We need to check for AllocateLocal() returning NULL. CopyFrom() takes
    care of that for us.  Also adjust a few other places in the code base
    that didn't have the check.

    The new test reproduces the crash, but in order to get this test file to
    execute, I had to move the xfail to be a function decorator. Apparently
    xfail as a statement causes the test to not run at all. We should run
    all of these queries even if they are non-determistic to at least verify
    that impalad does not crash.

    Change-Id: Iafefef24479164cc4d2b99191d2de28eb8b311b6
    Reviewed-on: http://gerrit.cloudera.org:8080/6761
    Reviewed-by: Dan Hecht <dh...@cloudera.com>
    Tested-by: Impala Public Jenkins


> Java UDF returning string can lead to crash under memory pressure.
> ------------------------------------------------------------------
>
>                 Key: IMPALA-5252
>                 URL: https://issues.apache.org/jira/browse/IMPALA-5252
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Backend
>    Affects Versions: Impala 2.8.0
>            Reporter: Alexander Behm
>            Assignee: Dan Hecht
>            Priority: Blocker
>              Labels: crash
>             Fix For: Impala 2.9.0
>
>
> Look at this code from hive-udf-call.cc HiveUdfCall::GetStringVal():
> {code}
> StringVal HiveUdfCall::GetStringVal(ExprContext* ctx, const TupleRow* row) {
>   DCHECK_EQ(type_.type, TYPE_STRING);
>   StringVal result = *reinterpret_cast<StringVal*>(Evaluate(ctx, row));
>   // Copy the string into a local allocation with the usual lifetime for expr results.
>   // Needed because the UDF output buffer is owned by the Java UDF executor and may be
>   // freed or reused by the next call into the Java UDF executor.
>   FunctionContext* fn_ctx = ctx->fn_context(fn_context_index_);
>   uint8_t* local_alloc = fn_ctx->impl()->AllocateLocal(result.len);
>   memcpy(local_alloc, result.ptr, result.len); <--- crash when local_alloc is nullptr
>   result.ptr = local_alloc;
>   return result;
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)