getTargetStreamer() might return null (e.g. when running
inlined-strings.ll test), downcasting to a reference will be wrong. This
is detectable with -fsanitize=null.
Details
- Reviewers
nemanjai steven.zhang - Group Reviewers
Restricted Project - Commits
- rG500b4ad5f4e5: [PowerPC] Fix downcast from nullptr for target streamer
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Missing test. And PPCAIXAsmPrinter::emitEndOfAsmFile also has issues if it could be null. And it seems that, we miss this check also in:
./AsmParser/PPCAsmParser.cpp: getParser().getStreamer().getTargetStreamer()); ./AsmParser/PPCAsmParser.cpp: getParser().getStreamer().getTargetStreamer()); ./AsmParser/PPCAsmParser.cpp: getParser().getStreamer().getTargetStreamer());
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | ||
---|---|---|
1416 | null check ? |
I don't have a good idea how to add test for this. With an ASAN build with -fsanitize=null, we get an error when running inlined-strings.ll.
It is better to have some tests. You can get it by adding assertion for TS and then, running the test to see if any test trigger this assertion. And please also fix this for PPCAIXAsmPrinter and PPCAsmParser together. Thank you.
Thanks for the advice, Steven. I found some existing tests that exercised the particular downcasting logic, and found that if I set -filetype=null in those RUN: directives, I could trigger a crash. So I added a line to those tests. Also made the same fix to PPCAsmParser and PPCAIXAsmPrinter.
null check ?