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 4 commits 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

@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.

@ianayl
Copy link
Contributor Author

ianayl commented Aug 6, 2025

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.

Looks like we don't have any testing for libsycl.so-gdb.py; the closest thing we have is https://github.com/intel/llvm/blob/sycl/sycl/test/gdb/printers.cpp, but this does not actually test the python printer script itself, but rather checks AST layouts.

Should I still go about updating said file to contain sycl::item? I had initially tried to extend this file to check that our classes contain fields that are as expected by the pretty printer, but as I actually started writing the test, I realized that since we never actually test-run libsycl.so-gdb.py, the test seems rather useless for my sakes: I assume we are trying to explicitly check if the pretty-printer has bugs in it, not whether or not SYCL RT has changes to it instead.

@uditagarwal97
Copy link
Contributor

Should I still go about updating said file to contain sycl::item?

Yes

@ianayl
Copy link
Contributor Author

ianayl commented Aug 7, 2025

I added a check in sycl/test/gdb/printers.cpp for sycl::item, checking for both MOffset and no MOffset: But as I mentioned prior, this test itself never actually runs the gdb printer 😅 it is effectively a lit test that checks SYCL constructs are as we expect them to be. I've added the test as requested, but I don't know if it does anything useful...

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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