You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Daniel Becker (Code Review)" <ge...@cloudera.org> on 2023/07/03 13:25:16 UTC

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Daniel Becker has uploaded this change for review. ( http://gerrit.cloudera.org:8080/20155


Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................

IMPALA-12260: Crash if '--asm_module_dir' is set

If Impala is started with the --asm_module_dir flag set and codegen
cache is used, Impala crashes.

The problem is with the lifetime of 'LlvmCodeGen::symbol_emitter_'. It
is registered as an event listener with the current
'llvm::ExecutionEngine'. Then the engine is cached but the
'LlvmCodeGen' object, which owns the symbol emitter, is destroyed at the
end of the query. When the cached execution engine is destroyed later,
it tries to notify the symbol emitter, but it has already been destroyed
so its pointer is invalid.

This change solves the problem by wrapping the execution engine and the
symbol emitter together in a wrapper class, LlvmExecutionEngineWrapper,
that is responsible for managing their lifetimes. The LlvmCodeGen and
the CodeGenCache classes now hold shared pointers to this wrapper class.
If we add other objects in the future whose lifetimes are tied to the
execution engine (but are not owned by it), they should be put into the
wrapper class.

Testing:
 - added a regression test in tests/custom_cluster/test_codegen_cache.py
   that fails without this change.

Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
---
M be/src/codegen/llvm-codegen-cache.cc
M be/src/codegen/llvm-codegen-cache.h
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
A be/src/codegen/llvm-execution-engine-wrapper.h
M tests/custom_cluster/test_codegen_cache.py
6 files changed, 162 insertions(+), 67 deletions(-)



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 2:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/20155/2/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/20155/2/be/src/codegen/llvm-codegen.cc@504
PS2, Line 504:   unique_ptr<CodegenSymbolEmitter> symbol_emitter = make_unique<CodegenSymbolEmitter>(id_);
line too long (91 > 90)



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 2
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Fri, 07 Jul 2023 23:59:40 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 1:

Build Failed 

https://jenkins.impala.io/job/gerrit-code-review-checks/13471/ : Initial code review checks failed. See linked job for details on the failure.


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Mon, 03 Jul 2023 13:40:26 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 3:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/13491/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 3
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Sat, 08 Jul 2023 00:22:14 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 5: Code-Review+2


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 5
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 13 Jul 2023 07:45:13 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 5:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/9500/ DRY_RUN=false


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 5
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 13 Jul 2023 07:45:14 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 3:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/20155/3/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/20155/3/be/src/codegen/llvm-codegen.cc@504
PS3, Line 504:   unique_ptr<CodegenSymbolEmitter> symbol_emitter = make_unique<CodegenSymbolEmitter>(id_);
line too long (91 > 90)



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 3
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Sat, 08 Jul 2023 00:00:32 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Daniel Becker (Code Review)" <ge...@cloudera.org>.
Daniel Becker has uploaded a new patch set (#4). ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................

IMPALA-12260: Crash if '--asm_module_dir' is set

If Impala is started with the --asm_module_dir flag set and codegen
cache is used, Impala crashes.

The problem is with the lifetime of 'LlvmCodeGen::symbol_emitter_'. It
is registered as an event listener with the current
'llvm::ExecutionEngine'. Then the engine is cached but the
'LlvmCodeGen' object, which owns the symbol emitter, is destroyed at the
end of the query. When the cached execution engine is destroyed later,
it tries to notify the symbol emitter, but it has already been destroyed
so its pointer is invalid.

This change solves the problem by wrapping the execution engine and the
symbol emitter together in a wrapper class, LlvmExecutionEngineWrapper,
that is responsible for managing their lifetimes. The LlvmCodeGen and
the CodeGenCache classes now hold shared pointers to this wrapper class.
If we add other objects in the future whose lifetimes are tied to the
execution engine (but are not owned by it), they should be put into the
wrapper class.

Testing:
 - added regression tests in tests/custom_cluster/test_codegen_cache.py
   that fail without this change.

Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
---
M be/src/codegen/llvm-codegen-cache-test.cc
M be/src/codegen/llvm-codegen-cache.cc
M be/src/codegen/llvm-codegen-cache.h
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
A be/src/codegen/llvm-execution-engine-wrapper.h
M tests/custom_cluster/test_codegen_cache.py
7 files changed, 208 insertions(+), 85 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/55/20155/4
-- 
To view, visit http://gerrit.cloudera.org:8080/20155
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 4
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Csaba Ringhofer (Code Review)" <ge...@cloudera.org>.
Csaba Ringhofer has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 3: Code-Review+1

Thanks for the fix, lgtm


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 3
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Tue, 11 Jul 2023 10:00:41 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 5: Verified+1


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 5
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 13 Jul 2023 16:50:43 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 4: Code-Review+1

(1 comment)

One more thing is that, have we done perf a-b test after the change? If not, can we run a perf a-b, for example tpch to compare with or without the change? It can ensure the cache working fine. Expect the performance should be similar.

http://gerrit.cloudera.org:8080/#/c/20155/3/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/20155/3/be/src/codegen/llvm-codegen.cc@1182
PS3, Line 1182: _wrapper_cached_ != nul
> There's a DCHECK in the constructor of LlvmExecutionEngineWrapper that chec
Yeah, you are right. Ack.



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 4
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Tue, 11 Jul 2023 15:29:56 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Daniel Becker (Code Review)" <ge...@cloudera.org>.
Daniel Becker has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 3:

(5 comments)

Thanks for the reviews.

http://gerrit.cloudera.org:8080/#/c/20155/1//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/20155/1//COMMIT_MSG@7
PS1, Line 7: asm_module_dir
> As we have discussed offline, it would be nice to add basic tests for other
Done


http://gerrit.cloudera.org:8080/#/c/20155/1/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/20155/1/be/src/codegen/llvm-codegen.cc@1193
PS1, Line 1193: ached execution 
> should be from the cached execution engine wrapper, but execution_engine() 
Done, thanks for catching this.


http://gerrit.cloudera.org:8080/#/c/20155/1/be/src/codegen/llvm-execution-engine-wrapper.h
File be/src/codegen/llvm-execution-engine-wrapper.h:

http://gerrit.cloudera.org:8080/#/c/20155/1/be/src/codegen/llvm-execution-engine-wrapper.h@33
PS1, Line 33: C
> nit: extra space
Done


http://gerrit.cloudera.org:8080/#/c/20155/1/tests/custom_cluster/test_codegen_cache.py
File tests/custom_cluster/test_codegen_cache.py:

http://gerrit.cloudera.org:8080/#/c/20155/1/tests/custom_cluster/test_codegen_cache.py@147
PS1, Line 147: e
> nit. one more full stop
Done


http://gerrit.cloudera.org:8080/#/c/20155/1/tests/custom_cluster/test_codegen_cache.py@152
PS1, Line 152:           impalad_args="--codegen_cache_capacity=2.5MB --perf_map")
             :   # Regression test for IMPALA-12260.
             :   def test_codegen_cache_with_perf_map(self, vector):
             :     self._test_codegen_cache_with_symbol_emitter(vector)
             : 
             :   def _test_codegen_cache_with_sym
> As we have discussed offline, it is unclear why exactly these queries lead 
Done



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 3
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Fri, 07 Jul 2023 23:58:56 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 2:

Build Failed 

https://jenkins.impala.io/job/gerrit-code-review-checks/13490/ : Initial code review checks failed. See linked job for details on the failure.


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 2
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Sat, 08 Jul 2023 00:14:32 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/20155/1/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/20155/1/be/src/codegen/llvm-codegen.cc@504
PS1, Line 504:   unique_ptr<CodegenSymbolEmitter> symbol_emitter = make_unique<CodegenSymbolEmitter>(id_);
line too long (91 > 90)



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Mon, 03 Jul 2023 13:26:09 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Csaba Ringhofer (Code Review)" <ge...@cloudera.org>.
Csaba Ringhofer has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 1:

(3 comments)

http://gerrit.cloudera.org:8080/#/c/20155/1//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/20155/1//COMMIT_MSG@7
PS1, Line 7: asm_module_dir
As we have discussed offline, it would be nice to add basic tests for other codegen debug outputs, e.g. perf_map to avoid breaking them in the future


http://gerrit.cloudera.org:8080/#/c/20155/1/be/src/codegen/llvm-execution-engine-wrapper.h
File be/src/codegen/llvm-execution-engine-wrapper.h:

http://gerrit.cloudera.org:8080/#/c/20155/1/be/src/codegen/llvm-execution-engine-wrapper.h@33
PS1, Line 33:  
nit: extra space


http://gerrit.cloudera.org:8080/#/c/20155/1/tests/custom_cluster/test_codegen_cache.py
File tests/custom_cluster/test_codegen_cache.py:

http://gerrit.cloudera.org:8080/#/c/20155/1/tests/custom_cluster/test_codegen_cache.py@152
PS1, Line 152:     q1 = """select int_col, tinyint_col from functional_parquet.alltypessmall
             :         order by int_col desc limit 20"""
             :     q2 = """select tinyint_col from functional_parquet.alltypessmall
             :         order by int_col desc limit 20"""
             :     q3 = """select year, month, count(*) from functional_parquet.alltypes group by 1, 2
             :         order by 1, 2 limit 100"""
As we have discussed offline, it is unclear why exactly these queries lead to a crash. It is a bit surprising for me that eviction happens with these not too complex queries.

If the event that triggers the crash is eviction, then we should check that self.get_metric('impala.codegen-cache.entries-evicted') > 0 after the queries, otherwise the test loses its coverage if no eviction will happen due to some change.



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Mon, 03 Jul 2023 14:38:24 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 4: Code-Review+2

LGMT. Thanks Daniel for working on this.


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 4
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 13 Jul 2023 02:25:35 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 5:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/9501/ DRY_RUN=false


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 5
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 13 Jul 2023 12:36:20 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 4:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/13521/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 4
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Tue, 11 Jul 2023 15:26:02 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Daniel Becker (Code Review)" <ge...@cloudera.org>.
Daniel Becker has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 4:

I ran a perf a-b benchmark: https://jenkins.impala.io/job/perf-AB-test/442

+----------+-----------------------+---------+------------+------------+----------------+
| Workload | File Format           | Avg (s) | Delta(Avg) | GeoMean(s) | Delta(GeoMean) |
+----------+-----------------------+---------+------------+------------+----------------+
| TPCH(42) | parquet / none / none | 3.91    | +0.72%     | 2.52       | +0.66%         |
+----------+-----------------------+---------+------------+------------+----------------+

+----------+----------+-----------------------+--------+-------------+------------+-----------+----------------+-------+----------------+---------+-------+
| Workload | Query    | File Format           | Avg(s) | Base Avg(s) | Delta(Avg) | StdDev(%) | Base StdDev(%) | Iters | Median Diff(%) | MW Zval | Tval  |
+----------+----------+-----------------------+--------+-------------+------------+-----------+----------------+-------+----------------+---------+-------+
| TPCH(42) | TPCH-Q20 | parquet / none / none | 1.63   | 1.58        |   +3.02%   |   2.52%   |   2.22%        | 50    |   +3.17%       | 5.85    | 6.25  |
| TPCH(42) | TPCH-Q17 | parquet / none / none | 1.99   | 1.92        |   +3.46%   |   5.55%   |   5.40%        | 50    |   +2.71%       | 2.92    | 3.10  |
| TPCH(42) | TPCH-Q19 | parquet / none / none | 1.28   | 1.25        |   +2.36%   |   1.51%   |   1.81%        | 50    |   +3.80%       | 6.21    | 7.01  |
| TPCH(42) | TPCH-Q2  | parquet / none / none | 0.70   | 0.68        |   +3.00%   |   3.85%   |   3.35%        | 50    |   +1.23%       | 4.28    | 4.08  |
| TPCH(42) | TPCH-Q14 | parquet / none / none | 1.80   | 1.78        |   +1.67%   |   2.13%   |   2.32%        | 50    |   +2.47%       | 3.78    | 3.71  |
| TPCH(42) | TPCH-Q21 | parquet / none / none | 20.34  | 19.94       |   +2.03%   |   0.91%   |   0.67%        | 50    |   +2.01%       | 7.78    | 12.51 |
| TPCH(42) | TPCH-Q15 | parquet / none / none | 2.35   | 2.33        |   +0.84%   |   1.79%   |   2.06%        | 50    |   +0.47%       | 2.37    | 2.17  |
| TPCH(42) | TPCH-Q1  | parquet / none / none | 4.91   | 4.87        |   +0.91%   |   1.97%   |   1.14%        | 50    |   +0.22%       | 2.36    | 2.82  |
| TPCH(42) | TPCH-Q9  | parquet / none / none | 10.95  | 10.89       |   +0.51%   |   1.52%   |   1.54%        | 50    |   +0.43%       | 1.35    | 1.68  |
| TPCH(42) | TPCH-Q18 | parquet / none / none | 10.15  | 10.17       |   -0.20%   |   1.30%   |   3.22%        | 50    |   +1.00%       | 1.64    | -0.41 |
| TPCH(42) | TPCH-Q11 | parquet / none / none | 0.58   | 0.58        |   +0.58%   |   3.74%   |   3.42%        | 50    |   +0.13%       | 1.34    | 0.81  |
| TPCH(42) | TPCH-Q5  | parquet / none / none | 2.05   | 2.04        |   +0.60%   |   1.47%   |   1.76%        | 50    |   +0.08%       | 1.58    | 1.85  |
| TPCH(42) | TPCH-Q16 | parquet / none / none | 1.54   | 1.54        |   +0.43%   |   1.76%   |   1.41%        | 50    |   +0.03%       | 1.52    | 1.35  |
| TPCH(42) | TPCH-Q7  | parquet / none / none | 2.96   | 2.95        |   +0.29%   |   2.35%   |   1.94%        | 50    |   +0.09%       | 0.65    | 0.67  |
| TPCH(42) | TPCH-Q12 | parquet / none / none | 1.54   | 1.54        |   +0.19%   |   1.90%   |   2.18%        | 50    |   +0.02%       | 0.39    | 0.47  |
| TPCH(42) | TPCH-Q3  | parquet / none / none | 3.81   | 3.81        |   +0.08%   |   1.38%   |   2.25%        | 50    |   -0.02%       | -0.74   | 0.23  |
| TPCH(42) | TPCH-Q4  | parquet / none / none | 2.05   | 2.05        |   -0.03%   |   1.23%   |   1.72%        | 50    |   +0.02%       | 0.83    | -0.09 |
| TPCH(42) | TPCH-Q13 | parquet / none / none | 6.79   | 6.81        |   -0.25%   |   0.75%   |   0.63%        | 50    |   -0.02%       | -1.57   | -1.81 |
| TPCH(42) | TPCH-Q6  | parquet / none / none | 0.71   | 0.71        |   -0.43%   |   2.11%   |   2.09%        | 50    |   -0.05%       | -1.31   | -1.03 |
| TPCH(42) | TPCH-Q8  | parquet / none / none | 2.59   | 2.61        |   -0.54%   |   2.29%   |   1.77%        | 50    |   -0.11%       | -1.25   | -1.32 |
| TPCH(42) | TPCH-Q10 | parquet / none / none | 3.27   | 3.31        |   -1.07%   |   2.07%   |   1.48%        | 50    |   -1.45%       | -2.64   | -3.00 |
| TPCH(42) | TPCH-Q22 | parquet / none / none | 1.92   | 1.97        |   -2.64%   |   1.91%   |   2.79%        | 50    |   -2.62%       | -4.86   | -5.58 |
+----------+----------+-----------------------+--------+-------------+------------+-----------+----------------+-------+----------------+---------+-------+


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 4
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 12 Jul 2023 09:33:55 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 1:

(2 comments)

Thanks Daniel for fixing this.
It looks good, one thing is that be/src/codegen/llvm-codegen-cache-test.cc seems compilation fails due to the change.

http://gerrit.cloudera.org:8080/#/c/20155/1/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/20155/1/be/src/codegen/llvm-codegen.cc@1193
PS1, Line 1193: execution_engine
should be from the cached execution engine wrapper, but execution_engine() returns the execution_engine_wrapper_


http://gerrit.cloudera.org:8080/#/c/20155/1/tests/custom_cluster/test_codegen_cache.py
File tests/custom_cluster/test_codegen_cache.py:

http://gerrit.cloudera.org:8080/#/c/20155/1/tests/custom_cluster/test_codegen_cache.py@147
PS1, Line 147: .
nit. one more full stop



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 05 Jul 2023 22:52:23 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 3: Code-Review+1

(2 comments)

Looks good to me. Minor nits.

http://gerrit.cloudera.org:8080/#/c/20155/3/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/20155/3/be/src/codegen/llvm-codegen.cc@1182
PS3, Line 1182: cached_execution_engine
nit. maybe also good to add DCHECK(cached_execution_engine != nullptr) here


http://gerrit.cloudera.org:8080/#/c/20155/3/be/src/codegen/llvm-execution-engine-wrapper.h
File be/src/codegen/llvm-execution-engine-wrapper.h:

http://gerrit.cloudera.org:8080/#/c/20155/3/be/src/codegen/llvm-execution-engine-wrapper.h@35
PS3, Line 35: 
            :    {
nit. can be compact format, no need for newline



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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 3
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Tue, 11 Jul 2023 14:16:43 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................


Patch Set 5: Verified-1

Build failed: https://jenkins.impala.io/job/gerrit-verify-dryrun/9500/


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 5
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Thu, 13 Jul 2023 12:04:59 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................

IMPALA-12260: Crash if '--asm_module_dir' is set

If Impala is started with the --asm_module_dir flag set and codegen
cache is used, Impala crashes.

The problem is with the lifetime of 'LlvmCodeGen::symbol_emitter_'. It
is registered as an event listener with the current
'llvm::ExecutionEngine'. Then the engine is cached but the
'LlvmCodeGen' object, which owns the symbol emitter, is destroyed at the
end of the query. When the cached execution engine is destroyed later,
it tries to notify the symbol emitter, but it has already been destroyed
so its pointer is invalid.

This change solves the problem by wrapping the execution engine and the
symbol emitter together in a wrapper class, LlvmExecutionEngineWrapper,
that is responsible for managing their lifetimes. The LlvmCodeGen and
the CodeGenCache classes now hold shared pointers to this wrapper class.
If we add other objects in the future whose lifetimes are tied to the
execution engine (but are not owned by it), they should be put into the
wrapper class.

Testing:
 - added regression tests in tests/custom_cluster/test_codegen_cache.py
   that fail without this change.

Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Reviewed-on: http://gerrit.cloudera.org:8080/20155
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
M be/src/codegen/llvm-codegen-cache-test.cc
M be/src/codegen/llvm-codegen-cache.cc
M be/src/codegen/llvm-codegen-cache.h
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
A be/src/codegen/llvm-execution-engine-wrapper.h
M tests/custom_cluster/test_codegen_cache.py
7 files changed, 208 insertions(+), 85 deletions(-)

Approvals:
  Impala Public Jenkins: Looks good to me, approved; Verified

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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 6
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Daniel Becker (Code Review)" <ge...@cloudera.org>.
Daniel Becker has uploaded a new patch set (#3). ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................

IMPALA-12260: Crash if '--asm_module_dir' is set

If Impala is started with the --asm_module_dir flag set and codegen
cache is used, Impala crashes.

The problem is with the lifetime of 'LlvmCodeGen::symbol_emitter_'. It
is registered as an event listener with the current
'llvm::ExecutionEngine'. Then the engine is cached but the
'LlvmCodeGen' object, which owns the symbol emitter, is destroyed at the
end of the query. When the cached execution engine is destroyed later,
it tries to notify the symbol emitter, but it has already been destroyed
so its pointer is invalid.

This change solves the problem by wrapping the execution engine and the
symbol emitter together in a wrapper class, LlvmExecutionEngineWrapper,
that is responsible for managing their lifetimes. The LlvmCodeGen and
the CodeGenCache classes now hold shared pointers to this wrapper class.
If we add other objects in the future whose lifetimes are tied to the
execution engine (but are not owned by it), they should be put into the
wrapper class.

Testing:
 - added a regression test in tests/custom_cluster/test_codegen_cache.py
   that fails without this change.

Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
---
M be/src/codegen/llvm-codegen-cache-test.cc
M be/src/codegen/llvm-codegen-cache.cc
M be/src/codegen/llvm-codegen-cache.h
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
A be/src/codegen/llvm-execution-engine-wrapper.h
M tests/custom_cluster/test_codegen_cache.py
7 files changed, 208 insertions(+), 85 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/55/20155/3
-- 
To view, visit http://gerrit.cloudera.org:8080/20155
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 3
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>

[Impala-ASF-CR] IMPALA-12260: Crash if '--asm module dir' is set

Posted by "Daniel Becker (Code Review)" <ge...@cloudera.org>.
Daniel Becker has uploaded a new patch set (#2). ( http://gerrit.cloudera.org:8080/20155 )

Change subject: IMPALA-12260: Crash if '--asm_module_dir' is set
......................................................................

IMPALA-12260: Crash if '--asm_module_dir' is set

If Impala is started with the --asm_module_dir flag set and codegen
cache is used, Impala crashes.

The problem is with the lifetime of 'LlvmCodeGen::symbol_emitter_'. It
is registered as an event listener with the current
'llvm::ExecutionEngine'. Then the engine is cached but the
'LlvmCodeGen' object, which owns the symbol emitter, is destroyed at the
end of the query. When the cached execution engine is destroyed later,
it tries to notify the symbol emitter, but it has already been destroyed
so its pointer is invalid.

This change solves the problem by wrapping the execution engine and the
symbol emitter together in a wrapper class, LlvmExecutionEngineWrapper,
that is responsible for managing their lifetimes. The LlvmCodeGen and
the CodeGenCache classes now hold shared pointers to this wrapper class.
If we add other objects in the future whose lifetimes are tied to the
execution engine (but are not owned by it), they should be put into the
wrapper class.

Testing:
 - added a regression test in tests/custom_cluster/test_codegen_cache.py
   that fails without this change.

Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
---
M be/src/codegen/llvm-codegen-cache.cc
M be/src/codegen/llvm-codegen-cache.h
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
A be/src/codegen/llvm-execution-engine-wrapper.h
M tests/custom_cluster/test_codegen_cache.py
6 files changed, 162 insertions(+), 67 deletions(-)


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

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I23f871abb962ad317f9c0075ca303c09dd56bcd9
Gerrit-Change-Number: 20155
Gerrit-PatchSet: 2
Gerrit-Owner: Daniel Becker <da...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>