Skip to content

[GLUTEN-10797][CH] Reject all JNI calls after native destroy is invoked#10815

Merged
lgbo-ustc merged 1 commit intoapache:mainfrom
bigo-sg:bug_0923_core
Oct 10, 2025
Merged

[GLUTEN-10797][CH] Reject all JNI calls after native destroy is invoked#10815
lgbo-ustc merged 1 commit intoapache:mainfrom
bigo-sg:bug_0923_core

Conversation

@lgbo-ustc
Copy link
Contributor

What changes are proposed in this pull request?

Reject all JNI calls after native destroy is invoked, to prevent access to invalid resources.

How was this patch tested?

test manually

@github-actions
Copy link

#10797

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

Copy link
Contributor

@zzcclp zzcclp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhztheplayer zhztheplayer changed the title [GLUTEN-10797][CH] Reject all JNI calls after native destroy is invoked. [GLUTEN-10797][CH] Reject all JNI calls after native destroy is invoked Oct 1, 2025
@github-actions
Copy link

github-actions bot commented Oct 9, 2025

Run Gluten Clickhouse CI on x86

for (auto it = active_executors_.begin(); it != active_executors_.end(); ++it)
{
auto * executor = *it;
executor->cancel();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check the result status? maybe fail or something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the result type of cancel is void

auto * executor = *it;
executor->cancel();
std::cerr << "Not closed LocalExecutor:\n" << executor->dumpPipeline() << std::endl;
delete executor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless, since active_executors_.clear(); will call dtor.

Copy link
Contributor Author

@lgbo-ustc lgbo-ustc Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are raw pointers, not shared_ptr

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

Run Gluten Clickhouse CI on x86

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

Run Gluten Clickhouse CI on x86

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

jbyteArray stringTojbyteArray(JNIEnv * env, const std::string & str);

// A watcher to monitor JNIEnv status: it's active or not
class JniEnvStatusWatcher
Copy link
Contributor

@zhanglistar zhanglistar Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better add

JniEnvStatusWatcher() = default;
    ~JniEnvStatusWatcher() = default;  

and set to private to avoid compiler autogenerate. Same as above other singleton classes.

{
public:
static JniEnvStatusWatcher & instance();
void active() { is_active.store(true, std::memory_order_release); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use setActive name as it does.

public:
static JniEnvStatusWatcher & instance();
void active() { is_active.store(true, std::memory_order_release); }
void inactive() { is_active.store(false, std::memory_order_release); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use setInactive name as it does.

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

Copy link
Contributor

@zhanglistar zhanglistar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little problem.

*/
#include "QueryContext.h"

#include <cstdint>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introduced by autocomplete

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

Copy link
Contributor

@zhanglistar zhanglistar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhanglistar
Copy link
Contributor

Good job and hope we can solve the early stop causing crash on CH BE.

@lgbo-ustc lgbo-ustc merged commit 1142ba4 into apache:main Oct 10, 2025
6 checks passed
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.

3 participants