Fix a potential crash in Frontend & Catalog JNI startup Bug: In the startup of the Frontend and the Catalog JVMs, we incorrectly use a local reference that can potentially be GC'ed by the JVM. Any usage of that reference can result in an undefined behavior or a JVM crash.
Fix: In GetThriftBackendGflags(), don't push the current JNI env into a local frame as that might GC the local references once SerializeThriftMsg() returns. Testing: We can reliably reproduce this crash with the dynamic log levels patch [1] in the following backend tests which start multiple Frontend instances in parallel. - buffered-block-mgr-test - buffered-tuple-stream-test - buffer-pool-test With this patch, all the above tests pass. [1] https://gerrit.cloudera.org/#/c/5792/ Change-Id: I35398a8efdb6fdbf7932a32489b2ad8d99b6d76f Reviewed-on: http://gerrit.cloudera.org:8080/6264 Reviewed-by: Bharath Vissapragada <[email protected]> Tested-by: Impala Public Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/ba2613ab Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/ba2613ab Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/ba2613ab Branch: refs/heads/master Commit: ba2613abfb39357843e0a6e5dfd2d5ed49b36ea3 Parents: 61c32a9 Author: Bharath Vissapragada <[email protected]> Authored: Sun Mar 5 13:56:45 2017 -0800 Committer: Impala Public Jenkins <[email protected]> Committed: Tue Mar 7 04:11:27 2017 +0000 ---------------------------------------------------------------------- be/src/util/backend-gflag-util.cc | 2 -- 1 file changed, 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/ba2613ab/be/src/util/backend-gflag-util.cc ---------------------------------------------------------------------- diff --git a/be/src/util/backend-gflag-util.cc b/be/src/util/backend-gflag-util.cc index da62b61..0781393 100644 --- a/be/src/util/backend-gflag-util.cc +++ b/be/src/util/backend-gflag-util.cc @@ -70,8 +70,6 @@ Status GetThriftBackendGflags(JNIEnv* jni_env, jbyteArray* cfg_bytes) { cfg.__set_lineage_event_log_dir(FLAGS_lineage_event_log_dir); cfg.__set_local_library_path(FLAGS_local_library_dir); cfg.__set_kudu_operation_timeout_ms(FLAGS_kudu_operation_timeout_ms); - JniLocalFrame jni_frame; - RETURN_IF_ERROR(jni_frame.push(jni_env)); RETURN_IF_ERROR(SerializeThriftMsg(jni_env, &cfg, cfg_bytes)); return Status::OK(); }
