You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Alex Behm (Code Review)" <ge...@cloudera.org> on 2016/10/29 04:49:07 UTC

[Impala-ASF-CR] IMPALA-4377: Add detailed error log when a UdfExecutorTest fails.

Alex Behm has uploaded a new change for review.

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

Change subject: IMPALA-4377: Add detailed error log when a UdfExecutorTest fails.
......................................................................

IMPALA-4377: Add detailed error log when a UdfExecutorTest fails.

This is not a fix for IMPALA-4377 but should help with diagnosing
the problem if we ever hit the failure again.

Change-Id: Id94130715e4f342e4dd2f6cd137ac1eb7b1ecf2d
---
M fe/src/test/java/org/apache/impala/hive/executor/UdfExecutorTest.java
1 file changed, 106 insertions(+), 57 deletions(-)


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id94130715e4f342e4dd2f6cd137ac1eb7b1ecf2d
Gerrit-PatchSet: 1
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Alex Behm <al...@cloudera.com>

[Impala-ASF-CR] IMPALA-4377: Fix Java UDF-arg buffer use-after-free in UdfExecutorTest.

Posted by "Matthew Jacobs (Code Review)" <ge...@cloudera.org>.
Matthew Jacobs has posted comments on this change.

Change subject: IMPALA-4377: Fix Java UDF-arg buffer use-after-free in UdfExecutorTest.
......................................................................


Patch Set 2: Code-Review+2

(1 comment)

http://gerrit.cloudera.org:8080/#/c/4881/2/fe/src/test/java/org/apache/impala/hive/executor/UdfExecutorTest.java
File fe/src/test/java/org/apache/impala/hive/executor/UdfExecutorTest.java:

PS2, Line 103: 
             : 
haha nice catch


-- 
To view, visit http://gerrit.cloudera.org:8080/4881
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id94130715e4f342e4dd2f6cd137ac1eb7b1ecf2d
Gerrit-PatchSet: 2
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Alex Behm <al...@cloudera.com>
Gerrit-Reviewer: Matthew Jacobs <mj...@cloudera.com>
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-4377: Fix Java UDF-arg buffer use-after-free in UdfExecutorTest.

Posted by "Internal Jenkins (Code Review)" <ge...@cloudera.org>.
Internal Jenkins has submitted this change and it was merged.

Change subject: IMPALA-4377: Fix Java UDF-arg buffer use-after-free in UdfExecutorTest.
......................................................................


IMPALA-4377: Fix Java UDF-arg buffer use-after-free in UdfExecutorTest.

The bug is simplest to explain with the old buggy test code below.
I added comments in the code to explain the bug.

// We used this for creating Text UDF arguments before invoking a UDF.
Writable createText(String v) {
  // Note that 'w' does not own the native buffer backing the string,
  // explained below.
  ImpalaTextWritable w = new ImpalaTextWritable(createStringValue(v));
  return w;
}

long createStringValue(String v) {
  byte[] array = v.getBytes();
  long ptr = allocate(16);
  UnsafeUtil.UNSAFE.putInt(ptr + 8, 0);
  ImpalaStringWritable sw = new ImpalaStringWritable(ptr);
  // This allocates a new native buffer and sets it as a member
  // of 'sw'. The native buffer is freed in sw.finalize().
  // However, after this function there are no more references
  // to 'sw', so the GC is allowed to free it. When that happens
  // the UDF argument's native memory is gone and we get garbage
  // UDF evaluations.
  sw.set(array, 0, array.length);
  return ptr;
}

This change also includes logging improvements to make similar
issues easier to diagnose in the future.

Testing: The bug was easy to reproduce by increasing the number
of runs in TestUdfImpl() to a large number. After this patch
I could not reproduce the issue anymore.

Change-Id: Id94130715e4f342e4dd2f6cd137ac1eb7b1ecf2d
Reviewed-on: http://gerrit.cloudera.org:8080/4881
Reviewed-by: Matthew Jacobs <mj...@cloudera.com>
Tested-by: Internal Jenkins
---
M fe/src/test/java/org/apache/impala/hive/executor/UdfExecutorTest.java
1 file changed, 119 insertions(+), 71 deletions(-)

Approvals:
  Matthew Jacobs: Looks good to me, approved
  Internal Jenkins: Verified



-- 
To view, visit http://gerrit.cloudera.org:8080/4881
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id94130715e4f342e4dd2f6cd137ac1eb7b1ecf2d
Gerrit-PatchSet: 3
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Alex Behm <al...@cloudera.com>
Gerrit-Reviewer: Internal Jenkins
Gerrit-Reviewer: Matthew Jacobs <mj...@cloudera.com>

[Impala-ASF-CR] IMPALA-4377: Add detailed error log when a UdfExecutorTest fails.

Posted by "Matthew Jacobs (Code Review)" <ge...@cloudera.org>.
Matthew Jacobs has posted comments on this change.

Change subject: IMPALA-4377: Add detailed error log when a UdfExecutorTest fails.
......................................................................


Patch Set 1: Code-Review+2

-- 
To view, visit http://gerrit.cloudera.org:8080/4881
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id94130715e4f342e4dd2f6cd137ac1eb7b1ecf2d
Gerrit-PatchSet: 1
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Alex Behm <al...@cloudera.com>
Gerrit-Reviewer: Matthew Jacobs <mj...@cloudera.com>
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-4377: Fix Java UDF-arg buffer use-after-free in UdfExecutorTest.

Posted by "Alex Behm (Code Review)" <ge...@cloudera.org>.
Hello Matthew Jacobs,

I'd like you to reexamine a change.  Please visit

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

to look at the new patch set (#2).

Change subject: IMPALA-4377: Fix Java UDF-arg buffer use-after-free in UdfExecutorTest.
......................................................................

IMPALA-4377: Fix Java UDF-arg buffer use-after-free in UdfExecutorTest.

The bug is simplest to explain with the old buggy test code below.
I added comments in the code to explain the bug.

// We used this for creating Text UDF arguments before invoking a UDF.
Writable createText(String v) {
  // Note that 'w' does not own the native buffer backing the string,
  // explained below.
  ImpalaTextWritable w = new ImpalaTextWritable(createStringValue(v));
  return w;
}

long createStringValue(String v) {
  byte[] array = v.getBytes();
  long ptr = allocate(16);
  UnsafeUtil.UNSAFE.putInt(ptr + 8, 0);
  ImpalaStringWritable sw = new ImpalaStringWritable(ptr);
  // This allocates a new native buffer and sets it as a member
  // of 'sw'. The native buffer is freed in sw.finalize().
  // However, after this function there are no more references
  // to 'sw', so the GC is allowed to free it. When that happens
  // the UDF argument's native memory is gone and we get garbage
  // UDF evaluations.
  sw.set(array, 0, array.length);
  return ptr;
}

This change also includes logging improvements to make similar
issues easier to diagnose in the future.

Testing: The bug was easy to reproduce by increasing the number
of runs in TestUdfImpl() to a large number. After this patch
I could not reproduce the issue anymore.

Change-Id: Id94130715e4f342e4dd2f6cd137ac1eb7b1ecf2d
---
M fe/src/test/java/org/apache/impala/hive/executor/UdfExecutorTest.java
1 file changed, 119 insertions(+), 71 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/81/4881/2
-- 
To view, visit http://gerrit.cloudera.org:8080/4881
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id94130715e4f342e4dd2f6cd137ac1eb7b1ecf2d
Gerrit-PatchSet: 2
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Alex Behm <al...@cloudera.com>
Gerrit-Reviewer: Matthew Jacobs <mj...@cloudera.com>

[Impala-ASF-CR] IMPALA-4377: Fix Java UDF-arg buffer use-after-free in UdfExecutorTest.

Posted by "Internal Jenkins (Code Review)" <ge...@cloudera.org>.
Internal Jenkins has posted comments on this change.

Change subject: IMPALA-4377: Fix Java UDF-arg buffer use-after-free in UdfExecutorTest.
......................................................................


Patch Set 2: Verified+1

-- 
To view, visit http://gerrit.cloudera.org:8080/4881
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id94130715e4f342e4dd2f6cd137ac1eb7b1ecf2d
Gerrit-PatchSet: 2
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Alex Behm <al...@cloudera.com>
Gerrit-Reviewer: Internal Jenkins
Gerrit-Reviewer: Matthew Jacobs <mj...@cloudera.com>
Gerrit-HasComments: No