PR/59070
Details
- Reviewers
jyknight int3 - Group Reviewers
Restricted Project - Commits
- rG65226d3f1f53: [lld-macho] Fix bug in CUE folding that resulted in wrong unwind table.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for tracking this down!!
lld/MachO/UnwindInfoSection.cpp | ||
---|---|---|
182 | nit: rm blank line | |
183 | nit 1: I think "largest" is more descriptive than "final" (plus "final" often has temporal-ordering connotations, e.g. InputSection::isFinal). Also maybe unwindAddressBoundary or cuAddressBoundary might be a better name for the variable, for similar reasons? nit 2: I don't think "this should covered folded entries as well" is a super clear explanation; I thought about how to elaborate on it, but then I think maybe it's better to let the reader figure that out by reading the comments in the implementation. I guess it's okay if you want to keep that line though. | |
464 | "remember" usually means "recall", rather than record/save. | |
660–661 | this is now unused | |
661–664 | I'm not entirely sure why, but this is what ld64 does | |
lld/test/MachO/compact-unwind-folding-bug.s | ||
2 ↗ | (On Diff #476565) | just to be clear, 'remove boilerplate' will include removing all the LSDA stuff, yes? we don't need to have a file that repros the actual no-catch bug, just something that checks that the last address of a bunch of folded CUEs is correct |
lld/MachO/UnwindInfoSection.cpp | ||
---|---|---|
661–664 | Adding 1 does make sense. This value is the start of the "next function", so it's an exclusive bound, and you want the final byte of the function to actually be included in the range. |
lld/MachO/UnwindInfoSection.cpp | ||
---|---|---|
661–664 | That was my initial thought too, but shouldn't adding the length already make it an exclusive bound? |
lld/MachO/UnwindInfoSection.cpp | ||
---|---|---|
661–664 | hmm yeah, looks like LD64 does add 1. (here and a couple of lines up in the secondLevelPages loop too). |
Thanks!
lld/MachO/UnwindInfoSection.cpp | ||
---|---|---|
183 | thanks for changing the comments! thoughts on the variable rename? | |
641 | ||
661–664 | or possibly to work around a mistake in the runtime unwinder... hard to say without carefully reading its implementation. @oontvoo I'll leave it up to you whether you want to leave the +1 in. We could certainly omit it and see if it causes any problems in practice. | |
lld/test/MachO/compact-unwind-folding-bug.s | ||
2 ↗ | (On Diff #476878) | How about
I'm also wondering if the test file name can have something more specific than "folding bug"... maybe compact-unwind-tail-folding.s? Because it's not a bug in folding in general, only when the fold happens at the tail entries of the CUE array. |
19 ↗ | (On Diff #476878) | (alternatively you could omit it entirely, MC emits stuff into .text by default) |
24–27 ↗ | (On Diff #476657) | can we remove more boilerplate? (likewise for the other functions) |
56–59 ↗ | (On Diff #476657) | why do we need this? |
lld/MachO/UnwindInfoSection.cpp | ||
---|---|---|
183 | changed to cueEndBoundary ? | |
661–664 | I'll remove the +1 since it seems wrong (ie., if there happens to be stuff after the last entry taht *shouldn't* be in it, then the table would still include it.) Also speaking of "strange", there seems to be another edge case here. I've added the test case below. Should we replicate this or not? (my guess is no, but /shrug) | |
lld/test/MachO/compact-unwind-folding-bug.s | ||
2 ↗ | (On Diff #476878) | How about just compact-unwind-folding.s? |
24–27 ↗ | (On Diff #476657) | We probably could - but slightly prefer that these symbols refer to each other (so that they don't look like they're all unused) |
lld/MachO/UnwindInfoSection.cpp | ||
---|---|---|
183 | sounds good! | |
lld/test/MachO/compact-unwind-folding-bug.s | ||
2 ↗ | (On Diff #476878) | sgtm! |
lld/test/MachO/compact-unwind-foldings.s | ||
7 | ||
59–60 | this makes sense to me, and I think we can keep our deviation from ld64's behavior here | |
61 | is this directive necessary? | |
85–86 | both ld64 and LLD do include an entry (with encoding 0x0) for this, right? I'm not sure there's a way to *not* include _d here, since if there isn't an entry with 0x0 encoding, then the unwinder just uses the CUE at the most recent preceding address. So I think ld64 is working correctly here | |
88 | ditto |
lld/test/MachO/compact-unwind-foldings.s | ||
---|---|---|
85–86 | right - when _d is in the middle of the range, we can't exclude it. |
nit: rm blank line