Skip to content

[GDB] Fix pretty-printer crash for sycl::item MOffset #19683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: sycl
Choose a base branch
from

Conversation

ianayl
Copy link
Contributor

@ianayl ianayl commented Aug 1, 2025

The pretty printer looks for an MOffset field in sycl::item impl without considering whether or not offset has been enabled (Offset was deprecated in SYCL 2020): Add a check to avoid printing MOffset if offset has been disabled.

@ianayl ianayl requested a review from a team as a code owner August 1, 2025 17:42
@ianayl ianayl requested a review from uditagarwal97 August 1, 2025 17:42
@uditagarwal97 uditagarwal97 requested a review from Copilot August 1, 2025 22:45
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a crash in the GDB pretty-printer for sycl::item objects when the MOffset field is not available. The fix adds exception handling to gracefully skip offset printing when the offset feature has been disabled (as deprecated in SYCL 2020).

  • Adds try-catch block around offset field access and printing logic
  • Prevents crashes when MOffset field is not present in sycl::item impl
  • Maintains backward compatibility for items with offset enabled

offset = SYCLIdPrinter(offset_id).value_as_string()
if offset not in ["0", "{0, 0}", "{0, 0, 0}"]:
string += ", offset " + offset
except:
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

Using a bare 'except:' clause catches all exceptions including system errors like KeyboardInterrupt. Consider catching specific exceptions like AttributeError or KeyError, or use 'except Exception:' to avoid catching system exceptions.

Suggested change
except:
except Exception:

Copilot uses AI. Check for mistakes.

if offset not in ["0", "{0, 0}", "{0, 0, 0}"]:
string += ", offset " + offset
except:
pass # device offset disabled
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

The comment 'device offset disabled' is misleading. Based on the PR description, this handles cases where offset has been disabled/deprecated in SYCL 2020, not specifically device offset. Consider updating to '# offset feature disabled (deprecated in SYCL 2020)' for clarity.

Suggested change
pass # device offset disabled
pass # offset feature disabled (deprecated in SYCL 2020)

Copilot uses AI. Check for mistakes.

@uditagarwal97
Copy link
Contributor

Do you know if it's feasible to add a test for this change? I don't recall seeing tests for sycl/gdb/libsycl.so-gdb.py TBH, so not sure if it's feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants