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 <[email protected]>
Gerrit-Reviewer: Matthew Jacobs <[email protected]>