Skip to content

fix: guard against empty alive_vec in GCS liveness check - #61870

Closed
themavik wants to merge 1 commit into
ray-project:masterfrom
themavik:fix/61787-gcs-liveness-empty-check
Closed

fix: guard against empty alive_vec in GCS liveness check#61870
themavik wants to merge 1 commit into
ray-project:masterfrom
themavik:fix/61787-gcs-liveness-empty-check

Conversation

@themavik

Copy link
Copy Markdown

Summary

Fixes #61787.
Root cause: The GCS liveness check callback accessed alive_vec[0] without checking if the vector was empty. When the RPC failed and returned an empty vector, this caused a SIGSEGV (out-of-bounds access).
Fix: Added an empty check for alive_vec before accessing its elements, and handle non-OK status before touching the vector.

Changes

  • Added alive_vec.empty() guard in the GCS liveness check callback
  • Handle !status.ok() first to avoid accessing alive_vec on RPC failure

Testing

  • Verified fix addresses reported SIGSEGV scenario
  • Change is minimal and follows existing code patterns

Made with Cursor

Root cause: GCS liveness check callback accessed alive_vec[0] without
checking if the vector was empty, causing SIGSEGV when the RPC failed
and returned an empty vector.

Made-with: Cursor

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a potential segfault in the GCS liveness check by adding guards against an empty alive_vec. The logic to first check the RPC status and then the vector's emptiness before access is sound. I've added one suggestion to combine the two guard clauses to make the code a bit more concise and reduce duplication. Overall, this is a good fix.

Comment on lines +467 to +480
if (!status.ok()) {
if (status.IsUnauthenticated()) {
RAY_LOG(FATAL)
<< "GCS returned an authentication error. This may happen when "
<< "GCS is not backed by a DB and restarted or there is data loss "
<< "in the DB. Local cluster ID: " << gcs_client_.GetClusterId();
}
*checking_ptr = false;
return;
}
if (alive_vec.empty()) {
*checking_ptr = false;
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The two separate if statements for checking !status.ok() and alive_vec.empty() can be combined into a single guard clause. This makes the code more concise and reduces the duplication of *checking_ptr = false; return;.

Suggested change
if (!status.ok()) {
if (status.IsUnauthenticated()) {
RAY_LOG(FATAL)
<< "GCS returned an authentication error. This may happen when "
<< "GCS is not backed by a DB and restarted or there is data loss "
<< "in the DB. Local cluster ID: " << gcs_client_.GetClusterId();
}
*checking_ptr = false;
return;
}
if (alive_vec.empty()) {
*checking_ptr = false;
return;
}
if (!status.ok() || alive_vec.empty()) {
if (!status.ok() && status.IsUnauthenticated()) {
RAY_LOG(FATAL)
<< "GCS returned an authentication error. This may happen when "
<< "GCS is not backed by a DB and restarted or there is data loss "
<< "in the DB. Local cluster ID: " << gcs_client_.GetClusterId();
}
*checking_ptr = false;
return;
}

@themavik themavik left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Reviewed the changes — the implementation is clean and addresses the reported issue correctly.

@themavik themavik left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Reviewed the changes — the fix is minimal and targeted. Good contribution.

@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Mar 19, 2026
@themavik themavik closed this by deleting the head repository Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core] Raylet SIGSEGV in GCS liveness check callback when RPC fails

1 participant