llvm-dwp did not check section identifiers read from input files. In the case of an unexpected identifier, the calculated index for Contributions[] pointed outside the array. This fix avoids the issue by skipping unsupported identifiers.
Details
Diff Detail
Event Timeline
Thanks!
Does the test need the debug_info section? (Probably needs them for some reason, might be worth mentioning)
Seems like the test should also have a tu_index to test the change there?
- The test was extended to add a TU index case.
- Added a comment to the test that the additional sections are required to reach the test points in the code.
- Extended the test by adding an unknown ID which is greater than DW_SECT_MACRO.
llvm/tools/llvm-dwp/llvm-dwp.cpp | ||
---|---|---|
250–252 | llvm-dwp does not emit anything for unknown sections and the patch is not changing that. |
llvm/test/tools/llvm-dwp/X86/unknown-section-id.s | ||
---|---|---|
2–9 | What does llvm-dwp do insteand of out of bounds access? Testing for "does anything other than crash" is usually a bad sign - presumably there's some specific behavior that we'd like llvm-dwp to have in these cases and should be testing for it here. |
llvm/test/tools/llvm-dwp/X86/unknown-section-id.s | ||
---|---|---|
2–9 | It just ignores the unknown sections because there is little it can do with them anyway. |
llvm/test/tools/llvm-dwp/X86/unknown-section-id.s | ||
---|---|---|
2–9 | Could we demonstrate that it does something else after the failure point and also that it doesn't try to dump the unknown sections? |
llvm/test/tools/llvm-dwp/X86/unknown-section-id.s | ||
---|---|---|
2–9 | Nothing comes to my mind. llvm-dwp creates the output, as usual. It ignores unknown sections, as usual. The only change is that it does not write to random memory locations, but that is not something that is easy to demonstrate; only UBSan catches that. Do you have any particular suggestions? |
llvm/test/tools/llvm-dwp/X86/unknown-section-id.s | ||
---|---|---|
2–9 | Perhaps at least show that the output contains only the expected sections maybe (not their contents)? |
What does llvm-dwp do insteand of out of bounds access? Testing for "does anything other than crash" is usually a bad sign - presumably there's some specific behavior that we'd like llvm-dwp to have in these cases and should be testing for it here.