The condition was not accurate enough and could interpret some FDEs in .eh_frame or 64-bit DWARF .debug_frame sections as CIEs. Even though such FDEs are unlikely in a normal situation, the wrong interpretation could hide an issue in a buggy generator.
Details
Diff Detail
Event Timeline
llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp | ||
---|---|---|
386 | Is there any way to break this up into subexpressions and helper variables that would make this condition more easy to follow? |
The two tests look like they have an FDE with no preceding CIE? Isn't that invalid?
Well, in one test that's on purpose, but the other one looks like it's being handled as if the input were actually valid.
The inputs are for sure invalid. The idea was to check that our consumer does not misinterpret them as valid CIEs as it did before the patch.
Well, in one test that's on purpose, but the other one looks like it's being handled as if the input were actually valid.
We allow FDEs without CIEs in .debug_frame, for good or bad. However, that is out of the scope of this patch.
Hmmm. I guess the next question is, do we have to bail out when something doesn't look right? Or can we keep going?
If we see an FDE with no preceding CIE, yes that's something we should report, but the not --crash tells me we are abandoning attempts to continue dumping the section. Does one of your other patches address this?
DWARFDebugFrame::parse() tends to call report_fatal_error() in case of any trouble; that was initially added in https://reviews.llvm.org/rG705085da37eed9557202ff1e86f9462842ef7af9 and than extended in D15535 (https://reviews.llvm.org/rG03a670c0ec1d38de8c206de1426340041f10f8ff).
While I agree that the parser should not crash the program on invalid input, resolving that lays a bit far away from my current intentions, which are just to add support for 64-bit values here.
Ping.
@probinson, do you suggest to change the intended behavior to crash on incorrect input before fixing this issue?
There is a longer-term effort to make parsing more tolerant, but I see that this is existing behavior in handling .debug_frame and you should not be required to fix it before committing this patch. However, I would appreciate it if you would file a bug about this, mentioning the eh-frame-cie-id.s test, so that the people trying to clean up the parsing behavior can be aware of it.
File that bug and LGTM.
Is there any way to break this up into subexpressions and helper variables that would make this condition more easy to follow?