Skip to content

[GLUTEN-12504][VL] Fix two null dereferences on BHJ stages in the micro benchmark - #12592

Open
malinjawi wants to merge 1 commit into
apache:mainfrom
malinjawi:fix/gluten-12504-bhj-microbenchmark
Open

[GLUTEN-12504][VL] Fix two null dereferences on BHJ stages in the micro benchmark#12592
malinjawi wants to merge 1 commit into
apache:mainfrom
malinjawi:fix/gluten-12504-bhj-microbenchmark

Conversation

@malinjawi

@malinjawi malinjawi commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

Part of #12504.

A stage containing a broadcast hash join could not be dumped or replayed, because of a null dereference on each side.

Replay: getJoin() dereferenced JniHashTableContext::vm_, which is only set from JNI_OnLoad, so converting a plan with a non-empty hashTableId crashed in a process with no JVM. Regression from #12487. callJavaGet() now returns std::optional and getJoin() reports a miss, the same 0 the JVM side cache returns and the converter already falls back on.

Dump: VeloxColumnarBatchWriter creates the parquet writer on the first batch, where it learns the schema, so an input iterator that yields nothing left it null and close() dereferenced it. A BHJ build side is such an iterator. close() is now a no-op when nothing was written, and the dumper records the gap as a .empty marker instead of reading back a file that was never created.

This does not make the benchmark exercise the real BHJ path. That is #12738.

How was this patch tested?

New jni_hash_table_test and velox_whole_stage_dumper_test, both running in the no-JVM configuration the benchmark uses.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code

@malinjawi malinjawi changed the title [GLUTEN-12504][VL] Fix segfault looking up BHJ hash table without a JVM [GLUTEN-12504][VL] Fix segfaults blocking BHJ stages in the micro benchmark Aug 3, 2026
@malinjawi
malinjawi force-pushed the fix/gluten-12504-bhj-microbenchmark branch from c8b995d to 0dc95cd Compare August 5, 2026 08:57
@malinjawi malinjawi changed the title [GLUTEN-12504][VL] Fix segfaults blocking BHJ stages in the micro benchmark [GLUTEN-12504][VL] Fix two null dereferences on BHJ stages in the micro benchmark Aug 5, 2026
@malinjawi
malinjawi force-pushed the fix/gluten-12504-bhj-microbenchmark branch from 0dc95cd to e160790 Compare August 10, 2026 09:23
…ro benchmark

getJoin() dereferenced JniHashTableContext::vm_, which is only set from
JNI_OnLoad, so converting a plan with a non-empty hashTableId crashed in a
process with no JVM. callJavaGet() now returns std::optional and getJoin()
reports a miss, the same way the JVM side cache reports one.

VeloxColumnarBatchWriter creates the parquet writer on the first batch, where it
learns the schema, so an input iterator that yields nothing left it null and
close() dereferenced it. A BHJ build side is such an iterator. close() is now a
no-op when nothing was written, and the dumper records the gap as a .empty
marker rather than reading back a file that was never created.
@malinjawi
malinjawi force-pushed the fix/gluten-12504-bhj-microbenchmark branch from e160790 to be3857f Compare August 10, 2026 10:01
@malinjawi
malinjawi marked this pull request as ready for review August 10, 2026 10:04
@malinjawi

Copy link
Copy Markdown
Contributor Author

@JkSelf @FelixYBW @zhouyuan Could you please review this PR regarding the BHJ fix in the microbench.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant