-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix Python exception when debugging. #51777
Conversation
r? @tromey or @michaelwoerister |
This PR is identical to #47617, so please address the comment in #47617 (comment). |
Oh, I hadn't noticed there was already a PR for this. Reading through that PR, I'm not sure I understand what changes are required, I'm more than happy to make any changes if clarified. (Also, while the other PR was closed, unless this change could break the pretty printer for some cases, it might be worthwhile considering a fix such as this as it's quite confusing when you run into the issue debugging, even if it is an accidental fix.) |
Ping from triage, @michaelwoerister, this PR needs your review. |
I'm still skeptical about merging an accidental fix. I'll try to set aside some time to find the root cause. |
Ping from triage @michaelwoerister! Did you find the root cause of this? |
I'm happy to help in debugging the issue (may need some pointers for what to look for and where to look) or in fixing it (probably with some mentoring instructions as I've not touched that part of the compiler). |
I compiled the test program from the other PR with rustc 1.27.0. Looking at the DWARF for
Following the type of the encoded member shows:
Following that type gives:
So here I think that the problem is that rustc isn't even following its own approach to representing optimized-out enums. In particular, I think that However, over in bug #32920, this whole area is being redone to be more correct -- instead of writing out special names, rustc will start using the correct DWARF structure to represent enums. However, because the patch for that bug will break all enum debugging for un-updated debuggers, I have been focusing my efforts on the lldb Rust plugin rather than on landing the patch. (It is still unclear to me if this is the best approach...) As to the patch in this PR -- I lean somewhat toward accepting it. It will only peel off extra layers of structs after the end of the list of encoded field numbers has been reached. In this sense it seems safe to me -- I don't think this situation could normally occur (and in fact it shouldn't occur, that's the underlying rustc bug). That said it does seem mildly risky since who knows what else might happen in some other situation. |
I'm still against just merging this. It clearly does the wrong thing in the general case. As @tromey pointed out, the
So the name should be To really solve this problem this function would have to be fixed: rust/src/librustc_codegen_llvm/debuginfo/metadata.rs Lines 1218 to 1239 in c0955a3
It seems that @eddyb even left a comment that this is broken :/
@tromey, do you know if it is safe to access the raw bytes of a local variable from the debugger/pretty-printer? If so, we could use |
Yes, it is fine. I'm getting close to getting lldb into rustup. And then I can land the real fix for the enum debuginfo bug, see https://github.com/tromey/rust/tree/enum-debuginfo-rebased |
That comment I left should mention #32920 but I'm not sure when that issue was opened. |
Ping from triage! @davidtwco it has been a while since the last time we heard from you, any update on this PR? |
I'll close this since it seems like @tromey and @michaelwoerister are nearly there with a fix for the underlying issue. |
During debugging, I would get the below exception. Looking into this a little, I found that changing the
is_null_variant
function to keep checking for fat pointers until finding the true discriminant fixed the issue. I'm not familiar with what this code should really be doing - so it's certainly possible that this fix makes no sense but it did stop the exception from happening, so there's that.Not sure who to assign for this, so I'll let the bot handle it.